Metadata storage in NFTs, IPFS and Limits
Upload your NFT file to IPFS, then a JSON metadata file that points to it, and pass the metadata's IPFS hash as the url when you mint. Max file size: 50 MB.
Tatum stores your NFT files on IPFS through Pinata. Each upload costs 2 credits. For an overview of IPFS and onchain storage with Tatum, see Blockchain storage.
- v3 REST API endpoint - Store data to IPFS
- JavaScript SDK - Upload a file to IPFS with the JavaScript SDK
IPFS file limit size is up to 50MB. File batch upload is unsupported.
Steps
Step_1: Upload an image, video, audio file, etc to IPFS
Example request:
- A successful request will return a response that includes an IPFS hash
curl --request POST \
--url https://api.tatum.io/v3/ipfs \
--header 'content-type: multipart/form-data' \
--header 'x-api-key: REPLACE_KEY_VALUE' \
-F file=@local_path_to_your_file_e_q_test-356.jpg
//Response:
{
"ipfsHash": "bafybeihrumg5hfzqj6x47q63azflcpf6nkgcvhzzm6f6nhic2eg6uvozlq/test-356.jpg"
}import {readFileSync} from 'fs';
import {ipfsGet, ipfsUpload} from '@tatumio/tatum';
/**
* Gets data from the IPFS
* @param id - IPFS CID of the file
*/
const ipfsId = await ipfsGet('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
*/
const ipfsHash = await ipfsUpload(readFileSync('logo.jpg'), 'logo.jpg');Step_2: Create a JSON metadata file
Create a JSON file with the metadata scheme to upload. The required fields are:
- Name of NFT
- Description of NFT
- IPFS hash from step_1
Example file
{
"name": "Lorem Ipsum Dolor Test",
"description": "Friendly Lorem OpenSea Creature that enjoys long swims in the ocean.",
"image": "ipfs://bafybeihrumg5hfzqj6x47q63azflcpf6nkgcvhzzm6f6nhic2eg6uvozlq/test-356.jpg"
}Step_3: Upload your saved JSON metadata scheme to IPFS
Example request:
- A successful request will return a response that includes an IPFS hash
curl --request POST \
--url https://api.tatum.io/v3/ipfs \
--header 'content-type: multipart/form-data' \
--header 'x-api-key: REPLACE_KEY_VALUE' \
-F file=@local_path_to_your_file_e_q_test-356.json
//Response:
{
"ipfsHash": "bafybeidi7xixphrxar6humruz4mn6ul7nzmres7j4triakpfabiezll4ti/metadata.json"
}Step_4: Include the response hash in the "url" of your NFT mint request
Example request:
//cURL && PrivateKey
curl --request POST \
--url https://api.tatum.io/v3/nft/mint \
--header 'content-type: application/json' \
--header 'x-api-key: REPLACE_KEY_VALUE' \
--data '{
"chain":"MATIC",
"tokenId":"100000",
"to":"0x687422eEA2cB73B5d3e242bA5456b782919AFc85",
"contractAddress":"0x687422eEA2cB73B5d3e242bA5456b782919AFc85",
"url":"ipfs://bafybeidi7xixphrxar6humruz4mn6ul7nzmres7j4triakpfabiezll4ti/metadata.json",
"fromPrivateKey":"{PRIVATE_KEY}"
}'
//cURL && KMS
curl --request POST \
--url https://api.tatum.io/v3/nft/mint \
--header 'content-type: application/json' \
--header 'x-api-key: REPLACE_KEY_VALUE' \
--data '{
"chain":"MATIC",
"tokenId":"100000",
"to":"0x687422eEA2cB73B5d3e242bA5456b782919AFc85",
"contractAddress":"0x687422eEA2cB73B5d3e242bA5456b782919AFc85",
"url":"ipfs://bafybeidi7xixphrxar6humruz4mn6ul7nzmres7j4triakpfabiezll4ti/metadata.json",
"index": 0,
"signatureId": "26d3883e-4e17-48b3-a0ee-09a3e484ac83", //must match existing wallet in your KMS instance
"nonce": 0 //optional usage. With high transaction volume, use manual nonce
}'import {Currency, mintNFTWithUri} from '@tatumio/tatum';
const transactionHash = await mintNFTWithUri(false, {
to: '0x687422eEA2cB73B5d3e242bA5456b782919AFc85',
url: 'ipfs://bafybeidi7xixphrxar6humruz4mn6ul7nzmres7j4triakpfabiezll4ti/metadata.json',
tokenId: '100000',
chain: Currency.MATIC,
contractAddress: '0x687422eEA2cB73B5d3e242bA5456b782919AFc85',
fromPrivateKey: '{PRIVATE_KEY}'
});Updated 3 days ago
Did this page help you?