ERC1155Metadata_URI

ERC1155Metadata_URI

Git Source

Inherits: ERC1155, Metadata

ERC1155 token with storage based token URI management.

Functions

uri

Returns the URI for token type tokenId.

Throws if _tokenURIs[tokenId] is not set.

function uri(uint256 tokenId) public view returns (string memory);

Parameters

Name
Type
Description

tokenId

uint256

The token ID to query.

Returns

Name
Type
Description

<none>

string

The URI of the token.

_mint

Mints a new token with a tokenURI.

This internal function MUST only be called in order to mint a new token with a tokenURI, i.e. not used to increment the supply of an existing token. This matters because the tokenURI MUST be set before transferring the control flow to _mint.

Parameters

Name
Type
Description

_to

address

The address to mint the token to.

_tokenId

uint256

The token ID; the child/derived contract is responsible for calculating it.

_value

uint256

The amount of tokens to mint.

_data

bytes

The data to associate with the token.

_setBaseURI

Sets the base URI.

token URI MUST be set before transfering the control flow to _mint, which could include external calls, which could result in reentrancy. E.g. https://medium.com/chainsecurity/totalsupply-inconsistency-in-erc1155-nft-tokens-8f8e3b29f5aa

Child contract MAY require access control to the external function implementation.

Parameters

Name
Type
Description

baseURI_

string

The new base URI.

Last updated