Contract-level metadata

Customizing the metadata for your smart contract

You can add a contractURI method to your ERC721 or ERC1155 contract that returns a URL for the storefront-level metadata for your contract.

contract MyCollectible is ERC721 {
    function contractURI() public view returns (string memory) {
        return "https://metadata-url.com/my-metadata";
    }
}

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": "external-link-url/image.png",
  "external_link": "external-link-url"
}

You can also encode 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);
    }
}