Nervos network works in a unique way to maximize decentralization while remaining minimal, flexible, and secure, but this uniqueness makes its operation substantially different from existing blockchains, thus making it necessary to define its own standards.
The Nervos Ecosystem offers a multilayer architecture to achieve scalability, security, and decentralization. The Nervos Blockchain is Layer 1 of this ecosystem and was thought to store the Common Knowledge Base generated in it. L1 Nervos network has a unique architecture, making it difficult to extrapolate existing standards from other blockchains.
This article proposes a standard for NFTs creation and handling, an example of an implementation of it with a modular programming perspective can be found in this article. This standard is aimed to provide a standardized structure so developers, users, and stakeholders have a common understanding of how things are done, making it easier to have integration between different Dapps and projects.
NRC-721 proposal is inspired by Openzeppelin’s implementation of ERC-721 from the Ethereum Blockchain as we consider this to be a mature, tested implementation proposal that actively makes it easier for Ethereum developers to deploy and integrate NFTs into their applications.
We aim to provide similar simplicity and lower the onboarding bar to the Nervos ecosystem.
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:
- code_hash: TYPE_ID or Custom Script
- type: "type"
- args: TYPE_ID [32 bytes]
- 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></code></pre>
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 of <span class='code-small'>base_token_uri</span> is to provide a detailed information source for the token. The path to fetch this info would use the <span class='code-small'>base_token_uri</span> as the base path along with the token <span class='code-small'>id:base_token_uri/token_id</span>, 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",
"description": "Identifies the asset to which this NFT represents"
"description": "Describes the asset to which this NFT represents"
"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.
The tokens cells contain the information of each unique token created from the factory and will be governed by the NFT script.
- code_hash: NFT_Script
- type: "type"
- args: Factory_code_hash<32 bytes> + Factory_type<uint8> + Factory_args<32 bytes> + TOKEN_ID
- Token specific data (can be empty)
Lock: <user defined></code></pre>
Using the factory cell type fields in the args of the token allows getting the information of the factory from the token Cell. This script should provide verification to ensure that each token has a unique <span class='code-small'>TOKEN_ID</span>, we propose using the Type_id logic here to achieve that.
Using NRC-721 in your application
Following we provide a summarized flow of how your Dapp would take advantage of this standard:
Stay tuned for more articles regarding efficient scripting in Nervos Network.
Rather Labs, Inc. | Github | LinkedIn
About Rather Labs.
Rather Labs is a Blockchain Technical partner who provides the blockchain expertise along with the partner intensity founders need.
Rather Labs is committed to work alongside our clients as a technical partner, providing insights, technical design, engineering team management, recommendations, maintenance and technology projection.
The company is led by co-founders which have been involved in blockchain projects in finance, real state, gaming, and other industries for years.
For more information, visit https://www.ratherlabs.com or follow the company on Medium https://medium.com/rather-labs and https://www.linkedin.com/company/ratherlabs