How to store metadata to IPFS and include it in an NFT
Use Tatum's native IPFS integration and free storage to easily upload NFT metadata.
Making NFTs with Tatum is just a matter of a few simple API calls. One very important step in the process is uploading your metadata (image, video, audio file, etc.) to IPFS and including it in your NFT. In this guide, you’ll learn how to do exactly that.
Why IPFS?
The InterPlanetary File System (IPFS) is a distributed file storage system that is perfect for storing NFT metadata. It ensures long-term data resilience and security, and now that Tatum has partnered with NFT.storage, you can store your files on it for free!
How to do it
We’ve built native IPFS integration into our platform, so you just need a couple of API calls to store your metadata.
First, upload your metadata (image, video, audio file, etc.) to IPFS using the following API call:
import {ipfsGet, ipfsGet} from'@tatumio/tatum';/** * Gets data from the IPFS * @param id - IPFS CID of the file */constipfsId=awaitipfsGet('QmXJJ6UF5WkF4WTJvsdhiA1etGwBLfpva7Vr9AudGMe3pj');/** * Upload file to the IPFS storage. * @param file - data buffer of the file. Content Type: multipart/form-data * @returns ipfsHash - IPFS hash of the file */constipfsHash=awaitipfsUpload('logo.jpg','fileName');
{"name":"Lorem Ipsum Dolor Test","description":"Friendly Lorem OpenSea Creature that enjoys long swims in the ocean.","image":"ipfs://bafybeihrumg5hfzqj6x47q63azflcpf6nkgcvhzzm6f6nhic2eg6uvozlq/test-356.jpg"}
And there you have it! You've successfully uploaded your metadata to IPFS, created a JSON metadata scheme containing the URL of the file, uploaded the scheme, and minted an NFT connected to it.