Closed taitruong closed 1 year ago
extension
can be used if you want to have some metadata stored on chain
(imo) since your contract should have a universal Metadata Extension type for all NFTs, you can customize your extension
however you want. Anytime someone wants to get information about an NFTs metadata, they should be able to query your contract and expect the metadata returned will follow the format you have defined in your extension
Having your Metadata stored on chain also allows other contracts to interact with it, which otherwise would not be possible if you had your metadata stored off chain (or at least would not be nearly as easy)
token_uri
can be used if you want to point to some metadata stored off chain
From cw721-base/state.rs
/// Universal resource identifier for this NFT
/// Should point to a JSON file that conforms to the ERC721
/// Metadata JSON Schema
pub token_uri: Option<String>,
From OpenSea metadata standards
...the uri function in your ERC1155 contract should return an HTTP or IPFS URL.
When queried, this URL should in turn return a JSON blob of data with the metadata for your token.
Since this is expected to just be JSON (and not a strongly typed Rust struct), there can't really be any guarantee of what the structure of that JSON will be. But, making a simple GET request is likely much more ergonomic than setting up a client and querying a node directly
Everything within the ERC-721 Enumeration Extension you posted is available by default with cw721-base (or has a comparable alternative)
ERC: totalSupply | CW721: num_tokens
ERC: tokenByIndex | CW721: nft_info
ERC: tokenOfOwnerByIndex | CW721: tokens
cw721-metadata-onchain - Core example of extending cw721-base with on-chain metadata
EnvoyLabs WhoamI - Example of a customized on-chain metadata extension
Closing for now, re-open if you have additional questions.
Quick question what
extension
means and is suppose to be: the purpose of cw721 extension is solely for metadata?Check here: https://github.com/CosmWasm/cw-nfts/blob/main/packages/cw721/src/query.rs#L120
But reading the ERC721 spec there are 2 types of extensions: metadata and enumeration metadata: https://eips.ethereum.org/EIPS/eip-721
Check here: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md