πŸ’ NFTs

Non-fungible Token Support

Chainlens has full support for NFTs. There are two types of NFT token supported. Those that support the original ERC-721 standard, and those that support the ERC-1155 multi-token standard.

You can access the NFT view in Chainlens by clicking the navigation item.

Common issues with NFTs

In order for NFTs to be rendered correctly in Chainlens, there are a few details that the creators need to get correct. Chainlens helps creators understand where the errors lies in the event that NFTs are not deployed correctly on the network.

Clicking this link takes you to the listing page for all NFTs.

From here you can click on a specific NFT and view information the collection its from.

If you click on a specific NFT you see information about it including its name, image, description and any attributes.

Additionally, we recognise that sometimes information is missing from NFTs preventing from them rendering correctly in explorers. To address this we've added additional information in Chainlens for users.

To unpack this, its helpful to discuss how NFTs are implemented on Ethereum networks.

Components of an NFT

NFTs are created by smart contracts implementing the ERC-721 or ERC-1155 standards.

ERC-721 is the original NFT standard. ERC-1155 came along later adding the ability to use a single smart contract for managing multiple collections of fungible and non-fungible tokens.

You'll see both types of tokens in Chainlens, where ERC-721 tokens are labelled Non-Fungible, whereas ERC-1155 are labelled Hybrid.

Metadata

Both standards contain an optional metadata extension which is used to provide information about the assets contained by NFTs.

These interfaces are below.

ERC-721 Metadata Interface

interface ERC721Metadata /* is ERC721 */ {
    /// @notice A descriptive name for a collection of NFTs in this contract
    function name() external view returns (string _name);

    /// @notice An abbreviated name for NFTs in this contract
    function symbol() external view returns (string _symbol);

    /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
    /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC
    ///  3986. The URI may point to a JSON file that conforms to the "ERC721
    ///  Metadata JSON Schema".
    function tokenURI(uint256 _tokenId) external view returns (string);
}

ERC-1155 Metadata Interface

interface ERC1155Metadata_URI {
    /**
        @notice A distinct Uniform Resource Identifier (URI) for a given token.
        @dev URIs are defined in RFC 3986.
        The URI MUST point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".       
        @return URI string
    */
    function uri(uint256 _id) external view returns (string memory);
}

This metadata extension, named tokenURI(uint256 _tokenId) and function uri(uint256 _id) in ERC-721 and ERC-1155 contracts respectively returns a URI string which can be used to obtain additional data about an NFT encoded in JSON.

This URI string will usually resolve to a URL. The URL is often hosted on the decentralised IPFS network, but it could be a location on a traditional storage location, such as an AWS S3 bucket.

The format of the JSON schemas is as per the below.

ERC-721 URI schema

{
    "title": "Asset Metadata",
    "type": "object",
    "properties": {
        "name": {
            "type": "string",
            "description": "Identifies the asset to which this NFT represents"
        },
        "description": {
            "type": "string",
            "description": "Describes the asset to which this NFT represents"
        },
        "image": {
            "type": "string",
            "description": "A URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive."
        }
    }
}

ERC-1155 URI schema

{
    "title": "Token Metadata",
    "type": "object",
    "properties": {
        "name": {
            "type": "string",
            "description": "Identifies the asset to which this token represents"
        },
        "decimals": {
            "type": "integer",
            "description": "The number of decimal places that the token amount should display - e.g. 18, means to divide the token amount by 1000000000000000000 to get its user representation."
        },
        "description": {
            "type": "string",
            "description": "Describes the asset to which this token represents"
        },
        "image": {
            "type": "string",
            "description": "A URI pointing to a resource with mime type image/* representing the asset to which this token represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive."
        },
        "properties": {
            "type": "object",
            "description": "Arbitrary properties. Values may be strings, numbers, object or arrays."
        }
    }
}

Correct NFT Deployment

When NFTs are minted on a network, for them to render correctly, they all need to be present in the smart contract creating the NFTs:

  • Lookup by token id returns a metadata URI

  • The metadata URI is accessible

  • The metadata URI contains an image URI property

  • This image URI is accessible and contains a valid image format

If any of the above steps fail then an NFT will not render correctly.

Given the series of stages required to render NFTs correctly, Chainlens now makes it clear where the problems lie when NFTs aren't being rendered correctly.

Digging Deeper into NFTs in Chainlens

When you navigate to an NFT collection page, the Collections tab displays the NFTs in the collection. Provided the NFT has been deployed correctly you will see preview images for individual NFTs in the collection.

Clicking on one of the NFTs will show you information about that specific NFT. In the below example, we have the name, NFT type, address, metadata URL and attributes.

If you click on the metadata URL hyperlink you will be able to see the metadata associated with the NFT.

In this instance, it's hosted on IPFS.

If there are any issues with the rendering of the NFT, it's straightforward to see where the problem lies.

  • If there is no metadata for the token, the metadata URL will be blank

  • If the metadata URL is not accessible, a No Metadata image is displayed

  • If the image URI is not accessible, a blank image is displayed

Last updated