ERC721Metadata_URI

ERC721Metadata_URI

Git Source

Inherits: ERC721, Metadata

This abstract contract provides functionality for managing URIs for ERC721 tokens.

Functions

tokenURI

Returns the URI for token type tokenId.

Throws if _exists(tokenId) is not true. The returned URI is the initial IPFS hash once the hex encoded base58 is converted to string.

function tokenURI(uint256 tokenId) external 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.

In this extension's _mint function, it is possible (although unintended) to mint two tokens with the same URI. This is because the derived contract's implementation is supposed to have access control so that only whitelisted minters can mint, i.e. trusted input.

Parameters

Name
Type
Description

_to

address

The address to receive the minted token.

_tokenId

uint256

The token ID to mint.

_data

bytes

The data bytes containing the token URI and any remaining data.

_burn

Burns a token.

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

See ERC721-_burn. Deletes the token URI upon burning.

Parameters

Name
Type
Description

_tokenId

uint256

The token ID to burn.

_setBaseURI

Sets the base URI.

This is an optional function that child contracts may require access control to the external function implementation.

Parameters

Name
Type
Description

baseURI_

string

The base URI to set.

Last updated