From 484cfde80ec0a467cf5055763d9d90c187110ffc Mon Sep 17 00:00:00 2001 From: dtbuchholz Date: Wed, 12 Oct 2022 17:56:03 -0700 Subject: [PATCH] docs: update & extend "Mutable NFTs" section This closes issues https://github.com/protocol/nft-website/issues/279, which describes the intent behind the PR. --- docs/guides/mutable-nfts.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/docs/guides/mutable-nfts.md b/docs/guides/mutable-nfts.md index e387ebf..b084e67 100644 --- a/docs/guides/mutable-nfts.md +++ b/docs/guides/mutable-nfts.md @@ -13,9 +13,20 @@ Today, these updates are frequently made by migrating the NFT to a new contract This guide walks through several ways to securely create and manage NFTs that change over time, also known as mutable NFTs. -## Background: IPFS Naming Services +## Background -IPFS creates immutable links (also known as content identifiers) based on a cryptographic hash of your data. This design is great for verifying that your data is correct, but once you’ve shared that CID with the world, what happens if you need to fix a typo? Or make a bigger change? +### Metadata Standards + +Before diving in, check out the overview of [metadata standards](https://nftschool.dev/reference/metadata-schemas) -- since every NFT needs to comply with ERC-721 metadata standards, it's important to understand what this entails. In particular, the section on [deeper & dynamic metadata](https://nftschool.dev/reference/metadata-schemas/#ethereum-and-evm-compatible-chains) walks through the current state of how people achieve mutable NFTs: + +1. Centralized hosting (not composable) +2. On-chain (expensive to mutate) +3. `tokenURI` changes that point to different IPFS CIDs (requires predefined knowledge of the NFT's end state) +4. Leverage web3 native solutions, like [Tableland](https://tableland.xyz/), which is augmented by IPFS or other related data services (see details below). + +### IPFS Naming Services ("IPNS") + +As an alternative to point #3 above, developers can also leverage IPNS. Recall that IPFS creates immutable links (also known as content identifiers) based on a cryptographic hash of your data. This design is great for verifying that your data is correct, but once you’ve shared that CID with the world, what happens if you need to fix a typo? Or make a bigger change? Naming services provide a way to map a consistent name to a changing address. That means that you can point to content in IPFS that may change, and people can still access it without needing to know the new hash beforehand. It’s perfect for pointing to the evolving assets of a mutable NFT. Naming services designed for IPFS include [IPNS](https://docs.ipfs.io/concepts/ipns/), [w3name](https://github.com/web3-storage/web3.storage/tree/main/packages/client#mutability), and [DNSLink](https://docs.ipfs.io/concepts/dnslink/). @@ -41,6 +52,16 @@ With this approach, each NFT would get a new stream and a stream identifier (str Updating the NFT metadata is as simple as writing new data to the stream. To render or use the NFT, you would fetch the streamID and process the commit log to get the latest state of the asset. As of now, Ceramic supports JSON data, so this would be a good way to manage mutable NFT properties and metadata as opposed to editable images or video. This approach might be best suited for NFTs that must be updated extremely frequently. -## Next steps +## Approach 3: The Best of Both Worlds + +[Tableland](https://tableland.xyz/) is a permissionless, serverless database. It extends blockchains to add native SQL functionality and mutable data while leveraging the same old Solidity with smart contracts + SQL as well as an SDK for client-side developers, and it works extremely well with the approaches outlined above. The protocol makes it extremely easy to create tables that store: + +- Descriptive metadata related to the IPFS, IPNS, or Ceramic identifiers (e.g., what is the file, date created, creator, etc.). +- _Mutable_ pointers to these solutions (e.g., update a cell from IPFS to IPNS to Ceramic). +- Use access controls for who can mutate the data, all with on-chain data (i.e., only allow a wallet / account with ownership of NFT ABC to mutate a value). +- Other related table data can be composed via SQL -- the off-chain Tableland network provides a gateway to make this easily accessbile to NFT marketplaces. + +This provides a number of unique advantages. Instead of storing a hardcoded IPFS, IPNS, or Ceramic stream identifier at the `tokenURI`, you can store a pointer to the Tableland gateway. The response from this endpoint could inclue IPFS (or other) identifiers and is ERC-721 compliant, allowing developers to pick and choose which table data is exposed in the ERC-721 metadata. A simple example is provided [here](https://testnet.tableland.network/query?mode=list&s=select%20json_object('name'%2C'Rig%20%23'%7C%7Cid%2C'external_url'%2C'https%3A%2F%2Ftableland.xyz%2Frigs%2F'%7C%7Cid%2C'image'%2Cimage%2C'image_alpha'%2Cimage_alpha%2C'thumb'%2Cthumb%2C'thumb_alpha'%2Cthumb_alpha%2C'attributes'%2Cjson_group_array(json_object('display_type'%2Cdisplay_type%2C'trait_type'%2Ctrait_type%2C'value'%2Cvalue)))%20from%20rigs_5_28%20join%20rig_attributes_5_27%20on%20rigs_5_28.id%3Drig_attributes_5_27.rig_id%20where%20id%3D1%20group%20by%20id%3B). Namely, developers can choose compose data across multiple web3-native SQL tables into a single object that is read by NFT marketplaces, including the IPFS-hosted image CID as part of the response. Simply create tables at the [Tableland registry smart contract](https://docs.tableland.xyz/deployed-contracts) (or use the [SDK](https://docs.tableland.xyz/javascript-sdk)), and write SQL directly in smart contracts or the URL! If you know SQL (which is one of the easiest languages to pick up), you know how to use Tableland. +## Next Steps Once you've considered these essential design decisions, you'll be better prepared to start building and testing your app — and releasing it to your users! If you come across any additional tips or tricks you find to be particularly helpful along your build journey, you're invited to share it here on NFT School to make building NFT dApps simpler and quicker for the developer community at large. Just [propose edits to this page on GitHub](https://github.com/protocol/nft-website/blob/main/docs/tutorial/mutable-nfts.md) or even write or [suggest new content](https://github.com/protocol/nft-website/issues/new?assignees=&labels=need%2Ftriage&template=content-or-feature-suggestion.md&title=%5BCONTENT+REQUEST%5D+%28add+your+title+here%21%29) — your fellow developers will thank you!