On-chain vs. Off-chain Metadata
NFTs are fundamentally smart contracts pointing to a series of metadata, and often include an artwork that exists as an image, as well as offering information regarding supply, origin, and authenticity.
The items on NFT platforms have unique features and there is a need to include them for identification. non-fungible token metadata offers information that describes a particular token ID. Applications related to NFTs need to access the information in the metadata.
NFT metadata is represented either on-chain or off-chain. On-chain means direct incorporation of the metadata into the smart contract which represents the tokens. On the other hand, off-chain representation means hosting the metadata separately.
On-chain metadata is located in the token’s smart contract. The representation of metadata on-chain has some merits:
- On-chain logic can dictate modifications to it; it is possible to change it.
- Since it is incorporated into the token, it stays there permanently and sustained beyond any application’s lifecycle.
When the owner of a digital art desires a lifelong value for an item, even when the platform used to create it and the NFT marketplaces currently listing it ceases to exist, developers can adopt on-chain metadata. This will sustain the metadata together and in cooperation with the token identifier’s lifecycle.
Further, it may be necessary to have interactions between on-chain logic and the metadata. In this case, there is a need for the logic within the smart contract to have access to the metadata from its internal state.
Metadata of numerous projects are stored off-chain because of the present storage limitations of the Ethereum blockchain. Developers use the ERC721 standard which features a method known as tokenURI. This method is implemented to let applications know the location of the metadata for a specific item. There are two solutions for off-chain storage: centralized servers and the InterPlanetary File System (IPFS).
Developers store metadata on centralized servers and cloud facilities such as Amazon Web Services (AWS). This is the simplest means of storing metadata. However, some of the demerits of this approach include:
- It is possible to change the metadata
- The disappearance of the metadata from the original source is possible if the project is no more online
However, to prevent the disappearance of metadata, a number of services will cache it on their own servers. This ensures efficient delivery to users even in a situation whereby the original hosting solution goes offline.
InterPlanetary File System (IPFS)
Developers within the digital art domain are now adopting the InterPlanetary File System (IPFS) for the storage of metadata off-chain. IPFS is a peer-to-peer file storage system used for hosting content across computers. It allows replication of a file in numerous different locations. The following are the merits of the InterPlanetary File System (IPFS):
- It ensures the immutability of the metadata, as the file’s hash addresses it specially.
- It ensures data persistence if long as there are nodes ready for its hosting.