-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SRC-7; Arbitrary Asset Metadata Standard #20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, happy to approve once @Braqzen 's comments are addressed
Is there any reason to enforce metadata to be stored by the same contract that mints the NFTs? It seems like this interface would support metadata for any AssetId, even if the contract doesn't own it. |
I believe the best practice would be to ensure that the contract that mints the asset implements the SRC-7 standard, hence requiring that the SRC-20 standard must also be implemented. With a sub id, anyone can verify that the asset was minted from the said contract. There could be security implications if another contract holds the metadata without a way to ensure that this data is valid. |
With metadata, can there be a function called token_uri, the same as erc-1155? This will make it easy to get NFT data. Because Mint will be considered an NFT, and just after that, there will be a call to get metadata (.json file) to store that data offline. |
While we intend to add an off-chain data retrival standard that focuses more on the implementation rather than an interface, to query a token's URI the "URI" key can be used. For example, here we are using the "URI" key: fn foo(contract_id: ContractId, asset: AssetId) {
// Use the SRC-7 standard to query any arbitrary contract without
// the need to know any other ABI implementations it may have
let contract_abi = abi(SRC7, contract_id);
// Define the key we want, in this case "URI"
let key = String::from_ascii_str("URI");
// Fetch the URI with the asset and key
let metadata = contract_abi.metadata(asset, key);
// Ensure the data we retrieved is what we expected
assert(metadata.is_some());
let string_data = match metadata.unwrap() {
Metadata::String(data) => data,
_ => revert(0),
}
} |
Here is some feedback regarding this standard (discussed with @dmihal earlier)
When attributes you want to standardise
For more inspiration, look what EtherScan, CoinGecko and TrustWalllet token repository offers as a metadata about the tokens. Happy to help you to come up with descriptions of key metadata attributes any asset should have. |
Yes absolutely agree that we should standardize attributes and keys along with what sort of data they return. Our intent is to do this across multiple categories which become living standards building atop this one, allowing for additions over time as needed as more projects get built out onchain. The first example of this is the SRC-8 standard which defines the metadata and keys for any bridged assets. |
## Type of change <!--Delete points that do not apply--> - New feature ## Changes The following changes have been made: - Splits the single file into multiple files and groups functions by standard - Adds helper functions for the `Metadata` type of the SRC-7 standard ## Notes - This will require FuelLabs/sway-standards#20 to be merged first --------- Co-authored-by: bitzoic <bitzoic.eth@gmail.com>
Type of change
Changes
The following changes have been made:
Notes
Related Issues
Closes #18