- NFT stands for non-Fungible token. Tokens that are unique, Digital, and not Interchangeable.
- NFTs have multiple applications and are constantly being developed for various other purposes.
- NFT is mostly based on the Ethereum blockchain and functions based on the code of their smart contract.
- It has many components that make the functioning smooth, and these components make the usage, storage, and working of an NFT easy.
- But there is so much to understand regarding these components and their functioning and storage.
In this article, we dive deep into On-Chain vs Off-Chain Transactions, Metadata, and On-Chain vs Off-Chain storage of Metadata.
On-Chain vs Off-Chain Transactions
- In on-chain transactions, transactions are made on the chain completely from start to end.
- When a trade needs to take place information for the transaction is transferred through a block that is a distributed Ledger to the receiving party.
- There are a lot of steps in this process and these transactions only take place after being mandated by the block and if the transaction is programmed in the smart contract of the block.
- Security is provided through the process and there is no scope for the displacement of data. The blocks are immutable, and any data cannot be erased.
- The entire process is completely decentralized and cannot be changed by anyone or a single or central entity.
- There is total transparency in the process. Transactions are recorded and validated across multiple locations and the full activity process can be viewed anytime.
- Time taken to process transactions it’s more because a lot of the transactions need to be mandated and are queued by the block.
- Transaction fees for the network are very high and the price rises when demand is greater which makes it very difficult.
- In the complete process of a transaction is not done on the blog then the transaction is called an off-chain transaction.
- Some part of the transaction is done off-chain by a third party and then the transaction is bought back on the chain for further processing.
Off-chain transactions harm the scalability of the blockchain but facilitate cheaper and faster transactions.
- The main block network does not need to confirm or mandate transactions and hence transactions are faster.
- Lower costs and no fees are required for processing
- Privacy is provided in all steps and data is secure and the user sender and receiver remain anonymous.
- There is less transparency and since many protocols are not followed for faster transactions there may be possibilities of the process being disrupted.
Before moving ahead and understanding On-Chain and Off-Chain storage, let us understand a few things about the metadata of an NFT, the blockchain, what are hash functions, and what is a smart contract.
- The blockchain is a peer-to-peer distributed Ledger system.
- Transactions made on the blockchain cannot be altered by any means.
- Blockchain is immutable, transparent, and secure.
- A hash function is a function on the blockchain used to map data present in a particular location.
- Hash is used to encoding information securely and easily and an NFT and all its data can be stored in a single hash function.
- A smart contract is a set of coded instructions present on the block.
- Smart contracts are the building blocks of NFTS and are also used to build decentralized applications.
Now the most important concept to understand is regarding the Metadata of the NFT.
Metadata of an NFT
- Properties and details that explain and define a certain digital asset are known as NFT metadata.
- The NFT’s file name, description, and information are listed in the metadata.
- Metadata is data that identifies NFT’s data and locates it.
- Metadata is responsible for all the portions of NFTS looks and functioning.
- NFT and NFT metadata are not placed together in most cases.
- Metadata is stored separately on blocks to preserve the value of the metadata and keep it secure from fraud.
- Metadata includes the data of what the NFT consists of and an attachment to audio, video, and pictures present in the NFT, and the transactional history of the NFT.
- Unique attributes of NFTs can be known using the Metadata of the NFT.
- Each ERC-721 standard block contains a Metadata string that defines the NFT.
- Storage of Metadata is very critical because it decides the proper existence of a singular NFT or the whole collection.
There are primarily two types of storage for Metadata Off-Chain and On-Chain. Developers must decide early on between the two.
On-Chain Metadata storage
- All the metadata information is composed on the blockchain.
- Data is permanently minted on the chain with NFT and cannot be erased.
- On-Chain logic interacts with the NFT for data and developers should give NFT the capability to understand this logic and reciprocate back.
- Because of this interaction between the chain and data, there may be some changes imparted permanently
- This way of storage is not much secure and can jeopardize the data of the NFD.
- any laws slash incidents on the blockchain will damage the NFT completely
- This system has failed previously and is not used mostly due to storage limitations on chains.
Pros and Cons of On-Chain NFT Metadata Storage
- All the NFT-related information the metadata, the smart contract, and the NFT itself, are stored in one place on the blockchain that cannot be altered by any external systems.
- On-Chain assets are more valuable because they need Ethereum network prerequisites and can be sold easily, they provide liquidity and are very trusted.
- The process of making NFT on the chain is complex and requires high-level skill in development.
- There are multiple Ethereum conditions to be met and it’s not easy to understand for a beginner.
Off-Chain Metadata Storage
- For high volumes of data to be stored and for easy access to chain metadata, NFTS are generally created and used.
- Data is either stored in a cloud or on servers.
- Most projects use Off-chain storage as there are plenty of limitations of On-chain Storage.
Pros and Cons of Off-Chain NFT Metadata Storage
- Data can be stored outside the blockchain and many ideas regarding blockchain are not required.
- High transaction costs can be avoided; in some cases, the NFT can be bought without a crypto wallet.
- Gas fees are excluded in all cases and are way cheaper to purchase.
- When there are problems with the storage linked the whole system collapses.
- Since the storage can be linked only once in the Metadata description there is no scope for any error to be made.
- Now that we have understood both these options and their Pros and Cons it can be said that there are exceptions in the systems and these exceptions can backfire and cause harm to investors.
- To completely secure the system even further the IPFS was started and developed which we can understand further.
- IPFS stands for Inter Planetary File System. It is an option for decentralized storage in WEB3 and is a multinode system.
- It is a peer-to-peer transaction system and stores metadata off-chain.
- IPFS is operated by Centralized mechanisms but is made for decentralized hosting of data.
- Metadata can be stored in these hosted locations.
- For the preservation of files, Metadata is generally stored in the IPFS.
- It is a network of independent storage providers.
- Reputed and trusted storage providers are found through Filecoin and these providers are given the responsibility of secured storage.
Now that we discussed what is IPFS we can discuss how does it works exactly?
How do IPFS and NFT work together?
- When an NFT needs to be viewed, the NFT requests to receive content to see and hear what is present in the NFT.
- Metadata gives a total description of specific token Id that needs to be retrieved.
- ERC-21 standard includes a method called token URI (Uniform Resource identifier).
- Token URI on query tells applications location to find metadata for a given NFT.
- We understood that IPFS is a distributed system that can be used to access files websites and data and other applications.
- IPFS has this system for finding content location and content and this is called content addressing.
- Each file that is stored in the IPFS is provided with a content ID after storage completion.
- IPFS uses content identifiers to get content from various places.
- when a file is requested, this task is set for a node to perform.
- As more and more people request a file a combination of nodes is formed and can be used for fulfilling the task.
- The task is split individually for the nodes.
- Decentralization uses content-based routing to perform these tasks.
- Data is stored in chunks of 256 KB, and these are called IPFS objects.
- Each file has a unique 24-character hash ID called content ID or CID. This is how content is addressed in the IFPS network.
- In short IPFS and Filecoin are complementary protocols for storing and sharing data on the distributed web.
- The fundamental idea is to make a simpler path for how people and computers communicate.
- IPFS works on a system of possession and participation of members.
- The token URI reverts after getting output from the IPFS system.
- Tokens data is permanent and cannot be altered.
- The JSON file contains the description, image, and URL of the source file.
- JSON file also contains project details like supply and encryption.
- To summarize the content, when a request is made to view an NFT the string that is attached to NFT raises a query for data in IPFS.
- The IPFS finds the required file using the content ID which is a unique 24-character ID for each set of data.
- The content addressing system finds this and reads the content.
- The content is reverted as a JSON file and this file provides information on the NFT.
Advantages of IPFS
- High bandwidth storage and a large amount of data can be generated quickly when required.
- Distribution of work is easily done, and every file has only one copy of it. This makes it authentic and cannot be duplicated easily.
Limitations of NFTS
- Much information about the asset cannot be gathered using NFTs.
- Data stored off-chain cannot be read by other smart contracts. Token URI is very necessary for this process but cannot be provided to the block.
- The data that is stored on the block which links it to off-chain storage cannot be updated for any reason, which is not quite suitable as there need to be multiple changes made over time.