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:
1
struct Header {
2
address host;
3
string name;
4
string symbol;
5
string uri;
6
}
Copied!
The singleton Main Interface contract integrates the DynamicMetadataCapableElement contract, so that it can provide 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:
1
function collectionUri(bytes32 collectionId) override external view returns(string memory) {
2
return _uri(collection[collectionId].uri, abi.encode(collectionId, 0));
3
}
Copied!
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:
1
function uri(uint256 itemId) override external view returns(string memory) {
2
ItemData storage itemData = item[itemId];
3
return _uri(itemData.header.uri, abi.encode(itemData.collectionId, itemId));
4
}
Copied!
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.
Copy link