Skip to content
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

Merged
merged 11 commits into from
Oct 2, 2023
Merged

SRC-7; Arbitrary Asset Metadata Standard #20

merged 11 commits into from
Oct 2, 2023

Conversation

bitzoic
Copy link
Member

@bitzoic bitzoic commented Sep 1, 2023

Type of change

  • New standard

Changes

The following changes have been made:

  • Introduces the SRC-7; Arbitrary Asset Metadata Standard

Notes

  • A separate standard will be defined for off-chain data retrieval
  • This PR will fail to compile until a new release of forc

Related Issues

Closes #18

@bitzoic bitzoic added the SRC-7 Label used to filter for the standard issue label Sep 1, 2023
@bitzoic bitzoic self-assigned this Sep 1, 2023
@bitzoic bitzoic requested a review from a team as a code owner September 1, 2023 10:58
@bitzoic bitzoic linked an issue Sep 1, 2023 that may be closed by this pull request
standards/src_7/src/src_7.sw Outdated Show resolved Hide resolved
standards/src_7/src/src_7.sw Outdated Show resolved Hide resolved
Copy link
Member

@K1-R1 K1-R1 left a 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

@bitzoic bitzoic requested review from K1-R1, Braqzen, dmihal and a team September 7, 2023 08:51
Braqzen
Braqzen previously approved these changes Sep 7, 2023
README.md Outdated Show resolved Hide resolved
standards/src_7/README.md Outdated Show resolved Hide resolved
standards/src_7/README.md Outdated Show resolved Hide resolved
@Voxelot
Copy link
Member

Voxelot commented Sep 7, 2023

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.

@bitzoic
Copy link
Member Author

bitzoic commented Sep 8, 2023

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.

standards/src_7/README.md Outdated Show resolved Hide resolved
@chappie1998
Copy link

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.

@bitzoic
Copy link
Member Author

bitzoic commented Sep 11, 2023

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),
     }
}

@miohtama
Copy link

miohtama commented Sep 14, 2023

Here is some feedback regarding this standard (discussed with @dmihal earlier)

  • Because on-chain is no longer expensive (it's not 2016 anymore) and metadata is very small, most of the data should be stored on-chain instead of an external source to avoid privacy and security issues (see here)
  • This information is going to be consumed by wallets, frontends and data indexers: have you engaged to discussions on any of these groups what they want to see on the metadata standard?
  • Not only the interface how to fetch data, but the data content itself must be standardised
  • You definitely want to have a method that fetches all data attributes once (to a some certain nice round limit like 256) attributes

When attributes you want to standardise

  • Website
  • Logo, various formats
    • Dark background
    • White background
    • Standard dimensions like 256x256, pick whatever Apple has decided
    • Note that sufficiently small logo files can be directly stored inline compressed on-chain, avoiding any issues with privacy leaks and exploits when fetching images
  • Social media links
    - Twitter
    - Discord
    - Telegram
    - etc.
  • Trading related
    • name; keypairs where to official trade the token
    • to avoid users landing on a phishing site through a Google
  • Security incident contact email

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.

@bitzoic
Copy link
Member Author

bitzoic commented Sep 20, 2023

Here is some feedback regarding this standard (discussed with @dmihal earlier)

  • Because on-chain is no longer expensive (it's not 2016 anymore) and metadata is very small, most of the data should be stored on-chain instead of an external source to avoid privacy and security issues (see here)
  • This information is going to be consumed by wallets, frontends and data indexers: have you engaged to discussions on any of these groups what they want to see on the metadata standard?
  • Not only the interface how to fetch data, but the data content itself must be standardised
  • You definitely want to have a method that fetches all data attributes once (to a some certain nice round limit like 256) attributes

When attributes you want to standardise

  • Website

  • Logo, various formats

    • Dark background
    • White background
    • Standard dimensions like 256x256, pick whatever Apple has decided
    • Note that sufficiently small logo files can be directly stored inline compressed on-chain, avoiding any issues with privacy leaks and exploits when fetching images
  • Social media links

    • Twitter
    • Discord
    • Telegram
    • etc.
  • Trading related

    • name; keypairs where to official trade the token
    • to avoid users landing on a phishing site through a Google
  • Security incident contact email

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.

@bitzoic bitzoic added the New Standard Label used to filter for the introduction of a new standard label Sep 20, 2023
@bitzoic bitzoic merged commit a3744aa into master Oct 2, 2023
1 check passed
bitzoic added a commit to FuelLabs/sway-libs that referenced this pull request Oct 4, 2023
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Standard Label used to filter for the introduction of a new standard SRC-7 Label used to filter for the standard issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SRC-7; Arbitrary Asset Metadata Standard
8 participants