ERC1155 uri(uint256) function shouldn't receive arguments

:computer: Environment

Latest version of OpenZeppelin (v4.0.0)


Why would we pass the id as argument if the contract won’t do anything with it?

:1234: Code to reproduce

1 Like

Hi @Mr.Peanutz,

The EIP ( specifies the interface which is uri(uint256).

function uri(uint256 _id) external view returns (string memory);

It also allows for {id} substitution.

The URI value allows for ID substitution by clients. If the string {id} exists in any URI, clients MUST replace this with the actual token ID in hexadecimal form. This allows for a large number of tokens to use the same on-chain string by defining a URI once, for that large number of tokens.

  • The string format of the substituted hexadecimal ID MUST be lowercase alphanumeric: [0-9a-f] with no 0x prefix.
  • The string format of the substituted hexadecimal ID MUST be leading zero padded to 64 hex characters length if necessary.

Example of such a URI: https://token-cdn-domain/{id}.json would be replaced with https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json if the client is referring to token ID 314592/0x4CCE0.

Which is why the function is implemented to meet the EIP specification but use a single uri for gas saving on minting.