Dynamic On-chain Metadata Integration

The Item standard is the first token standard in the Ethereum Ecosystem to natively integrate the Dynamic on-chain Metadata protocol. The Item Main Interface can manage dynamic or traditional uri for each Item and each Collection.

All the Collection of Items and all the Items can have dynamic on-chain Metadata. The uri string both for Collection and Items is passed as the uri parameter in the Header struct:

struct Header {
    address host;
    string name;
    string symbol;
    string uri;
}

The singleton Main Interface contract integrates some functions used to easily interact with the Dynamic on-chain Metadata protocol to generate dynamic Metadata directly from the chain.

The first one is the collectionUri function:

function collectionUri(bytes32 collectionId) override external view returns(string memory) {
    return _uri(collection[collectionId].uri, abi.encode(collectionId, 0));
}

It takes as input a collectionId and internally calls the _uri function passing:

  • the uri string of the Collection as the _plainUri parameter.

  • the encoded collectionId as the additionaldata parameter.

The output of the function is the rendered string.

The _uri function provided by the DynamicMetadataCapableElement will call the resolve function of the Resolver and it will manage the uri calling the Renderer contract.

The second one is the uri function:

function uri(uint256 itemId) override external view returns(string memory) {
    ItemData storage itemData = item[itemId];
    return _uri(itemData.header.uri, abi.encode(itemData.collectionId, itemId));
}

It takes as input an itemId and internally calls the _uri function passing:

  • the uri of the Item as the _plainUri parameter, taking it from its Header.

  • the encoded collectionId and itemId as the additionaldata parameter.

The output of the function is the rendered string.

The _uri function provided by the DynamicMetadataCapableElement will call the resolve function of the Resolver and it will manage the uri calling the Renderer contract.

Last updated