Factory Cell

In order to store the common data without repeating and paying for unnecessary storage space in the blockchain a factory Cell is defined to store common data:

Type:
 - code_hash: TYPE_ID or Custom Script
 - type: "type"
 - args: TYPE_ID [32 bytes]
Data:
 - name: length<uint8> + text<utf-8> (max 255 char)
 - symbol: length<uint8> + text<utf-8> (max 255 char)
 - base_token_uri: length<uint8> + text<utf-8> (max 255 char)
Lock: <user defined>

Since we need some mechanism to ensure that this cell is unique, we recommend using the Type ID proposed here. For that purpose, the nervos blockchain offers a built-in type_id script that can be used without the need of developing and deploying a custom script, but, when looking for custom features on the factory, a specific script should be developed implementing the type_id functionality, plus the custom features. The data on this cell should be verified on the NFT script to ensure compatibility with the standard, so the script should require using the factory as a dependency.

The purpose ofbase_token_uri is to provide a detailed information source for the token. The path to fetch this info would use the base_token_uri as the base path along with the token id:base_token_uri/token_id, and it should return a JSON object with the extra info. For this JSON object, we adopt Ethereum’s ERC721 Metadata JSON 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."
    }
  }
}

Referencing the Ethereum standard will allow straightforward cross-chain integration with blockchains that have already adopted it.

Last updated