Recently, with the growth of the Conflux ecosystem, a large number of high-quality applications are developed in Conflux, especially the NFT-related ones. However, this also leads to a problem of varying contract quality and standard compatibility.
Therefore, for the prosperity and sustainability of NFT applications on the Conflux chain, the integration between applications, and contract quality and security, all Conflux NFT developers are advised to read this article carefully.
Following the standards
NFT developers should read and fully comply with the EIP-721 or EIP-1155 standard.
It is recommended that applications that do not have use cases where both FT and NFT are used adopt and follow the EIP-721 standard.
The standard contract interface and implementation can be found at:
EIP-721: https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC721
EIP-1155: https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC1155
The NFT metadata URI address, obtained from the URI or tokenURI method, is recommended to use the placeholder format, instead of storing one URI per tokenId.
Off-chain NFT JSON metadata should follow the Metadata section in each standard document. It is recommended that both EIP-721 and EIP-1155 should follow the Metadata JSON Schema of EIP-1155 to include fields such as name, image, description, etc., and using the same localization standards for multilingual support (rather than using non-standard structures and fields, such as name_en).
Future ConfluxScan or wallet applications may stop supporting or only provide limited support for contracts that do not fully comply with the EIP-721 or EIP-1155 standard.
Building Conflux Contracts Library
The repo above contains common contract tools used by Conflux, such as built-in contracts, 721/1155 extensions, etc. Developers can use them as needed.
All developers are welcome to submit issues or pull requests to enrich the contract library.
Enumerable
Due to the additional gas cost to users, the enumerable extension is optional in EIP-721. It has been even removed from the EIP-1155 standard.
The gas cost is low on the Conflux chain, and there is a unique sponsor mechanism. Therefore, developers who have a strong need for the enumerable extension in EIP-1155 contracts can use the extensions in the Conflux contract library to implement it.
The enumerable extension can discover the NFTs that have been minted by contracts or owned by users. Implementing it in a contract will bring additional storage and gas costs, so developers need to carefully weigh the pros and cons beforehand. If the above functionality is needed in an application, it is highly recommended to implement it off-chain. In the future, ConfluxScan may provide relevant services for contracts that fully follow the standards to replace the enumeration functionality.
Enumerable Gas Cost Comparison
call safeTransferFrom, tokenId: 1, amount: 1, data: 0x
If EIP-1155 contracts need to implement Enumerable, it is recommended to do so based on the CRC1155 presets.
Condition | Ethereum | Conflux |
---|---|---|
IERC721Enumerable Unsupported | Code txHash Gas Used: 61,564 |
Code txHash Gas Used: 53,704 Storage Deposit: 128 |
IERC72Enumerable Supported | Code txHash Gas Used: 87,888 |
Code txHash Gas Used: 75,828 Storage Deposit: 192 |
IERC1155Enumerable Unsupported | Code txHash Gas Used: 53,514 |
Code txHash Gas Used: 42,356 Storage Deposit: 64 |
IERC1155Enumerable Supported | Code txHash Gas Used: 123,547 |
Code txHash Gas Used: 76,689 Storage deposit: 256 |
With Enumerable supported, the mint operation will cost more storage deposits.
Condition | Conflux |
---|---|
IERC721Enumerable Unsupported | Code txHash mint Gas Used: 37,796 mint Storage Deposit: 128 |
IERC721Enumerable Supported | Code txHash mint Gas Used: 64,296 mint Storage Deposit: 320 |
IERC1155Enumerable Unsupported | Code txHash mint Gas Used: 34,974 mint Storage Deposit: 64 |
IERC1155Enumerable Supported | Code txHash mint Gas Used: 74,013 mint Storage Deposit: 512 |