ERC721ATokenURIFacet

ERC721ATokenURIFacet

Implements the facet for managing token URIs for ERC 721 tokens, based on our ERC721A implementation. This is designed to be extensible in the future.

_mode0TokenURI

function _mode0TokenURI(uint256 tokenId) internal view returns (string)

tokenURI

function tokenURI(uint256 tokenId) public view returns (string)

Returns the Uniform Resource Identifier (URI) for tokenId token. Throws URIQueryForNonexistentToken if tokenId does not exist.

Parameters

Name
Type
Description

tokenId

uint256

uint256 ID of the token to query.

Return Values

Name
Type
Description

[0]

string

string URI of given token.

mode0BaseTokenURI

function mode0BaseTokenURI() public view returns (string)

Returns the mode0BaseTokenURI which is used to construct the tokenURI for mode 0 and overrides for other modes execpt 99. See setMode0BaseTokenURI for details.

Return Values

Name
Type
Description

[0]

string

string The base token URI which is used to create the final tokenURI.

setMode0BaseTokenURI

function setMode0BaseTokenURI(string baseTokenURI_, bool refresh) external

Sets the baseTokenURI. When mode 0 is active or others are overriden, this is used as the base for the tokenURI. The tokenURI is then composed of [mode0BaseTokenURI] + [string stored via setTokenURI] Requires ROLE_ACCESS_CONTROL_ADMIN membership.

Parameters

Name
Type
Description

baseTokenURI_

string

The new baseTokenURI, which must end with a forward slash. Example: 'ipfs://' with the tokenURIs set as an IPFS hash.

refresh

bool

True to trigger a metadata refresh.

mode1BaseTokenURI

function mode1BaseTokenURI() public view returns (string)

Returns the baseTokenURI which is used to construct the tokenURI for mode 1. See setMode1BaseTokenURI for details.

Return Values

Name
Type
Description

[0]

string

string The baseTokenURI.

setMode1BaseTokenURI

function setMode1BaseTokenURI(string baseTokenURI_, bool refresh) external

Sets the baseTokenURI for mode 1 The {tokenURI} for mode 1 is composed of [mode1BaseTokenURI] + [tokenId] + '.json'. Requires ROLE_ACCESS_CONTROL_ADMIN membership.

Parameters

Name
Type
Description

baseTokenURI_

string

The new baseTokenURI for mode 1, which must end with a forward slash. Example: https://myserver.com/metadata/

refresh

bool

True to trigger a metadata refresh.

mode2BaseTokenURI

function mode2BaseTokenURI() public view returns (string)

Returns the baseTokenURI which is used to construct the tokenURI for mode 2. See setMode2BaseTokenURI for details.

Return Values

Name
Type
Description

[0]

string

string The baseTokenURI.

setMode2BaseTokenURI

function setMode2BaseTokenURI(string baseTokenURI_, bool refresh) external

Sets the baseTokenURI for mode 2. The {tokenURI} for mode 2 is composed by [mode2BaseTokenURI] + [thisContractsAddress] + '/' + [chainId] + '/' + [tokenId] + '.json'. Requires ROLE_ACCESS_CONTROL_ADMIN membership.

Parameters

Name
Type
Description

baseTokenURI_

string

The new baseTokenURI for mode 2, which must end with a forward slash. Example: https://meta.roji.io/

refresh

bool

True to trigger a metadata refresh.

defaultTokenURI

function defaultTokenURI() external view returns (string)

Returns the defaultTokenURI. Used when no other tokenURI is set or mode 99 is active.

Return Values

Name
Type
Description

[0]

string

string The default token URI.

setDefaultTokenURI

function setDefaultTokenURI(string tokenURI_, bool refresh) external

Sets the setDefaultTokenURI. This should be a fully qualified URL or empy string or data URL. Requires ROLE_ACCESS_CONTROL_ADMIN membership.

Parameters

Name
Type
Description

tokenURI_

string

The new default token URI.

refresh

bool

True to trigger a metadata refresh.

setTokenURIMode

function setTokenURIMode(uint256 mode, bool refresh) external

Sets the mode.

Parameters

Name
Type
Description

mode

uint256

The new mode. Valid modes are 0, 1, 2 and 99. Other values will resolve to mode 0

refresh

bool

True to trigger a metadata refresh.

tokenURIMode

function tokenURIMode() external view returns (uint256)

Returns the active tokenURI mode.

Return Values

Name
Type
Description

[0]

uint256

uint256 The tokenURIMode.

setTokenURI

function setTokenURI(uint256 tokenId, string tokenURI_, bool refresh) external

_Sets a specific tokenURI_ for tokenId. This is the default for mode 0 and overrides mode 1 and 2

Requires ROLE_ADMIN_MINTING membership._

Parameters

Name
Type
Description

tokenId

uint256

The id of the token to set the URI for.

tokenURI_

string

The new token URI.

refresh

bool

True to trigger a metadata refresh.

Was this helpful?