Contract-level metadata
Customizing the metadata for your smart contract
You can add a contractURI
method to your ERC-721 or ERC-1155 contract that returns a URL for the collection-level metadata, as specified by ERC-7572.
contract MyCollectible is ERC721 {
function contractURI() public view returns (string memory) {
return "ipfs://QmTNgv3jx2HHfBjQX9RnKtxj2xv2xQDtbVXoRi5rJ3a46e";
// or e.g. https://external-link-url.com/my-contract-metadata.json
}
}
This URL should return data in the following format:
{
"name": "OpenSea Creatures",
"description": "OpenSea Creatures are adorable aquatic beings primarily for demonstrating what can be done using the OpenSea platform. Adopt one today to try out all the OpenSea buying, selling, and bidding feature set.",
"image": "https://external-link-url.com/image.png",
"external_link": "https://external-link-url.com",
"collaborators": ["0x0000000000000000000000000000000000000000"]
}
You can also encode and return the data within the contract itself:
contract MyCollectible is ERC721 {
function contractURI() public pure returns (string memory) {
string memory json = '{"name": "Opensea Creatures","description":"..."}';
return string.concat("data:application/json;utf8,", json);
}
}
To specify creator earnings settings for your contract, set it on the Royalty Registry which OpenSea will use.
Updated 1 day ago