How to store NFT metadata decentralized and dynamically
xutweety
Posted on December 20, 2022
image from https://blog.chain.link/what-is-a-dynamic-nft/
It is difficult for the metadata in dNFT(dynamic NFT) to achieve “decentralization” and “dynamic change” at the same time.
Decentralized metadata storage
About 48% of NFT (most NFTs are static) metadata is decentralized and stored on IPFS. The format suffix is ipfs/your_collection_file_hash/tokenid
, where your_collection_file
refers to the NFT collection, where tokenid
is a number, such as “26”. An example of such a project is Bored Ape Yacht Club, the metadata of which is stored in IPFS, although the BaseURI used for IPFS can be changed by the contract owner.
Suppose the platform wants to provide NFT customization capabilities and put metadata in decentralized storage. In that case, developers need to exhaust all possible combinations of attributes, put all the varieties of metadata on IPFS, and then index according to the combination of attributes to find the tokenURI in IPFS to get the metadata.
The disadvantages of this approach are:
There are many metadata combinations, leading to much storage cost in advance. You have to store them all in advance.
If the platform wants to add a Smartglasses option to the feature of Glasses, or when it provides the ability to change dynamically, it can change the metadata information in the NFT about the game level and other metadata information in the NFT according to the goals of the World Cup during a match. At this point, the timeliness requirements for metadata changes are higher. For example, this dynamic change almost equals replacing a new NFT, and the cost of changing NFT metadata will rise sharply.
Dynamically update first
The second method is to abandon the decentralized metadata storage and only put the ownership on the Chain to ensure timely and rapid dynamic changes. Some projects generate metadata through a centralized server, and the metadata information of the customized NFT will be combined and generated in a centralized manner.
To be able to display different houses in 2022 and 2027, NFT minter should first put other roofs on the Chain, store metadata off the Chain, and the URL of a centralized service to do the correlation, pointing to one of them in 2022, and replacing it in 2037 to another one.
However, they store metadata on their central storage, and these servers can fail in the blink of an eye, costing NFT owners millions worldwide.
More importantly, it isn’t easy to guarantee that such storage will not be tampered with. Especially for some game NFTs, their value does not lie in the displayed pictures but in the information that is crucial in the game, such as force values, levels, etc. This information is stored in metadata. It is impossible to guarantee that only the owner of the NFT owner who can change the metadata based on centralized storage.
And when the metadata storage is separated from data on the Chain, the dynamic metadata history does not leave traces on the Chain, and the two are unrelated, so it isn’t easy to carry out practical analysis and insight.
Currently, only the first two columns of data are kept on-chain, which you can see directly from platforms like OpenSea. But you only know that the price is increasing over time, but you need to understand why. The last data column is in the platform’s centralized server, which is unreliable. For example, a sharp price increase in 2029 is due to the repair of a new roof — the information about this is in the third column of metadata. Because the metadata is changing and is not stored on the Chain, it may be tampered with, so you cannot know, nor is it challenging to analyze and understand what a more reasonable price in 2037 is. These problems may lead to a poor display experience of dNFT in the NFT trading market, making it difficult for dNFT to circulate and prosper in the secondary market.
For example, in OpenSea, a dNFT that changes with the daily sunshine conditions rotates the animation every 8 hours, the change history of metadata is not presented on the website, and the dynamic feature is completely invisible when you first enter it. You have no way of knowing this is dynamic.
Put all the things on the Chain.
Therefore, it is best to put all metadata, images, transaction information, etc., on the Chain and can add the metadata and change it conveniently and dynamically. Your signature should perform the changes, and the NFT platform as an intermediary minimizes the direct touch of data (reading and writing, caching, etc.).
DB3 network
Here, let me introduce the DB3 network, a decentralized storage solution that adopts the key-value storage paradigm and has advanced database properties, such as mutation and programmability.
Change metadata easily based on a decentralized storage.
DB3 can support convenient CRUD-like operations, insert, update, read and delete stored data. This is easy to achieve for centralized storage, but it is challenging to accomplish for decentralized storage. The reason is that the update operation conflicts with the immutable characteristics of the blockchain. But in use cases such as the dynamic NFT mentioned above, immutable storage is important from a security point of view, but it limits the number of possible applications (such as the evolutionary ability of NFT).
A mutation is defined in the DB3 network as our core concept. All operations on data modification are defined as mutation. You can use mutation to insert, update and delete data. For example, you can easily complete the data renewal when you want to modify roof color meatada.
>put house roofcolor offwhite
submit mutation to mempool done!
>get house roofcolor
roof -> offwhite
At the same time, mutation can perform data update operations, and the other three: insert/update/delete and the hash returned by these operations will be submitted to the block.
Analyze metadata history onchain
Every metadata change of dNFT will be recorded on the chain like a snapshot. At the same time, because we have optimized the efficiency of our storage engine, we can achieve high-performance queries, not inferior to the web2 database. Therefore, in the future, analysis of dNFT will be very easy to read and display a more credible metadata history.
Claim metadata ownership
Secondly, the description information of dNFT will be stored in a concept similar to the “table” in web2. Since the metadata defines the asset, securing metadata is as important as securing ownership. The operation and modification of this table need to obtain the user’s permission, which is completely controlled by the user, ensuring the ownership of dNFT. The centralized service should barely touch metadata.
Our Github:
Browse some design docs;
Start coding from goodfirstissue;
Discuss with us according the WIPissue.
Posted on December 20, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.