How to Store NFT Off-chain Data on Crust
* NFT off-chain metadata is generally some media files, such as pictures, videos, etc. These files are suitable for storage using IPFS.
* NFT trading platform uses the Crust network to store files, which can ensure accessibility, security and decentralization of the files stored on the IPFS network.
* Crust provides free storage space for early-stage developers. For more details, please visit: http://fs.crust.network/
* NFT trading platform can flexibly customize a more appropriate Crust storage order strategy according to the features of media files on the platform, such as the file size and creation frequency.
Essentially, NTFs consist of smart contracts and metadata. In the NFT collections or NFT games scenario, metadata generally contains media files such as pictures and videos. Due to lack of storage resources on the chain, these metadata are generally stored off-chain. When these NFTs are created, they will carry a link pointing to the off-chain metadata. At present, many NFT metadata links point to the URL provided by the centralized server, for example: `https://cloud-bucket.provider.com/my-nft.jpeg`
When the above link becomes the only way to access the NFT media files, the service provider can easily modify or delete the files on the server, thus no one can guarantee that the NFT media files will not be tampered with. On the other hand, if the centralized server is shut down without any reason, or the file is damaged, the NFT metadata will be lost forever.
Due to the nature of IPFS content addressing, each NFT media file added on IPFS will get a CID (Content ID), the only ID for this file on the IPFS network. Everyone can safely share, download and verify the corresponding NFT media file through this CID. Therefore, IPFS is suitable for the storage and distribution of NFT media files.
Crust provides accessibility guarantees for the files stored on the IPFS network. Users can store files on the Crust network in a decentralized manner, so that the files can be stored reliably on the IPFS network for a long time.
The following process introduce how the NFT trading platform store the files to the IPFS network through Crust network:
NFT Data Storage Process Based on Crust Network
1. Users create NFT media files on the NFT trading platform
During the NFT creation process, users need to upload media files, such as pictures and videos corresponding to the NFT to the platform server. (The storage of media files on the NFT trading platform we mentioned here is a kind of cache. After the files are stored on the Crust network in step 3, the NFT media files cached on the platform can be deleted);
2. NFT trading platform upload the media files on the IPFS network
After receiving the users’ files, the NFT trading platform needs to upload them on the IPFS network. If the platform has a local IPFS service, they can upload the local IPFS directly. If not, they can upload the files to IPFS through Gateway.
3. NFT trading platform initiates a storage order on the Crust network
Once the NFT media files are saved on the IPFS network, you will get a CID. Through this CID, you can initiate a storage order on the Crust network. The Crust network node will monitor the storage order and pull the NFT media files corresponding to the order. On average, each order file will be distributed and stored on the Crust network, and finally will be saved on the majority of IPFS nodes.
4. Write the IPFS link corresponding to the NFT in the NFT MetaData
When the media files are stored into the Crust network, users can access these files in the form of IPFS Gateway + file CID. For example, file QmUmfSj43T9fsPSaEgGcrgHH5Wq8KFv48oVXnfY4FXDJZt can be accessed through the link https://ipfs.decoo.io/QmUmfSj43T9fsPSaEgGcrgHH5Wq8KFv48oVXnfY4FXDJZt.
5. NFT trading platform can delete the local cached media files
When the media files are stored on the Crust network, their accessibilities and accessibilities have been guaranteed. Therefore, the NFT trading platform can delete the media files that have been saved by the Crust network.
Some details that can be optimized
The backend of the NFT trading platform can monitor the file storage status through Crust SDK, such as the expiration time of the file and the copies of the file. According to this information, you can renew the file that is about to expire or have expired in time to ensure the accessibility of the file.
For NFT trading platforms that have not applied for free storage space, it is necessary to ensure that there is enough CRU balance to pay for the storage of new files.
It is recommended that developers choose the suitable storage order strategy, thereby reducing the number and costs of storage orders.
We provide free storage service for early developers, but in the long run, we recommend that developers adapt to local conditions and flexibly customize a more appropriate Crust storage order strategy according to the features of media files on the platform, such as the file size and creation frequency.
For example, compared to placing a storage order in Crust for each small file, the NFT trading platform can cache multiple media files in a folder locally, and initiate a storage order for this folder, which can effectively reduce the storage order number, thereby reducing the order fees. Although multiple media files exist in one storage order, each file can still be accessed through its own CID.
The Advantages of NFT Storage on Crust
The NFT media data stored in the Crust network will be extremely accessible. As each NFT media file will be stored by more than 100 IPFS nodes in the Crust network, the accessibility of the NFT media data in the Crust network will be greater than 99.99 (36 9's)%.
Users will get multi-point acceleration when accessing NFT media files. As we mentioned above, there are more than 100 copies of NFT media files in the Crust network. When users retrieve files directly through IPFS, they can get multiple transmissions from multiple copy nodes, which increases the download speed.
Based on IPFS, it ensures that NFT media files cannot be tampered with. The feature of IPFS content addressing ensures the correspondence between CID (content ID) and specific data, and ensures that the accessed content cannot be forged.