How to create NFTs

Collectibles in the blockchain are just one API call away.

The ERC-721 token is a standardized smart contract with a predefined set of features. The tokens are non-fungible, which means that each one is unique. You can think of them as one-of-a-kind collectibles.

NFTs have been making waves in the digital world recently and for good reason. These specialized tokens ensure verifiable authenticity and scarcity of digital assets, opening up a world of possibilities for a wide range of digital marketplaces.

From digital collectibles to in-game assets to one-of-a-kind releases of digital media, the possibilities are endless. Everyone wants to start implementing NFTs into their platforms, but they're running into a few obstacles.

Creating a new NFT, or "smart contract" on an Ethereum-compatible blockchain, is not easy at all. As a developer, you have to know a lot of things:

  • Solidity - a new programming language for writing smart contracts

  • How to use a compiler for Solidity

  • How to develop using an IDE

  • How to deploy the compiled smart contract

It's a lot to know, and for developers who only need the basic features of ERC-721 tokens, it would take weeks to figure it all out.

This is why we've made prebuilt ERC-721 smart contracts that are ready to deploy with one API. You can easily create NFTs without learning Solidity and can deploy them on your blockchain of choice.

Check out the source code to our ERC-721 smart contract on GitHub.

In this guide, you will learn how to deploy an ERC-721 smart contract, and to mint, transfer, and burn tokens. Please also check out our workshop on working with NFTs for a live demo of the workflow in Postman:

You can find all of the API calls we will be using in our API documentation or download our Postman collection for this guide here.

Tatum currently supports the following blockchains for deploying our prebuilt NFTs:

  • Ethereum

  • Polygon (Matic)

  • Celo

  • Harmony.ONE

  • Tron

  • Flow

  • Binance Smart Chain

Deploying an NFT Smart Contract

To create and deploy NFTs using Tatum, all you need is one simple API call. This API call deploys a standard, validated NFT smart contract to the blockchain of your choice.

In this example, we are using Celo because it is fast, cheap and you can pay for transactions with a stable coin (cUSD). However, you can deploy an NFT smart contract on any other supported blockchain with the same API call by changing the name of the blockchain in the "chain" field of the call.

The required parameters are the name and symbol of the deployed token, the initial supply of the tokens, and the recipient address where the initial supply will be transferred.

Blockchain transactions are signed using a private key via API, which is not a secure way of signing transactions. Your private keys and mnemonics should never leave your security perimeter. To correctly and securely sign a transaction, you can use Tatum CLI from the command line, a specific language library like Tatum JS, the local middleware API, or our complex key management system, Tatum KMS.

The following API call will deploy an NFT smart contract on Celo:

Request
Response
Request
curl --location --request POST 'https://api-eu1.tatum.io/v3/nft/deploy' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"symbol": "COLLECTIBLE",
"name": "CollectibleToken",
"chain": "CELO",
"fromPrivateKey": "0x4874827a55d87f2309c55b835af509e3427aa4d52321eeb49a2b93b5c0f8edfb",
"feeCurrency": "CUSD"
}'
Response
{
"txId": "0xa61f21f5c33996f7e8a6d209513fb446ea345565f10e614e40a7978e3373b919"
}

Getting the contract address

The response to the above call is a transaction ID . Using the transaction ID, we can use the Get contract address from transaction endpoint to obtain the address of the NFT smart contract.

Request
Response
Request
curl --location --request GET 'https://api-eu1.tatum.io/v3/nft/transaction/CELO/0xa61f21f5c33996f7e8a6d209513fb446ea345565f10e614e40a7978e3373b919' \
--header 'x-api-key: YOUR_API_KEY'
Response
{
"blockHash": "0xb67611ef02119da1082883acd6453ebc64655ed31c3b345d184050a808c3bebc",
"blockNumber": 9814820,
"contractAddress": "0x1860Cf5A199892BC527A0698e7be08a7C6Bc6064",
"gas": 4500000,
"gasPrice": "119000000000",
"gasUsed": 4446222,
...
...
}

In the response, you can see a field called "contractAddress," which contains the address of the smart contract.

Minting a new unique ERC-721 token

When your NFT smart contract is deployed and you know the contract address, you can issue new unique tokens with the Mint NFT endpoint. This endpoint will create a new token with a unique identifier. Every token should have metadata as a JSON schema containing additional information about the token, like the image URL, description, etc. This metadata is the "content" of the NFT and usually links to a picture, video, audio file, or another type of digital asset on IPFS or another hosting service. To upload and retrieve data to IPFS natively using Tatum, please have a look at our Storage/IPFS endpoints.

Request
Response
Request
curl --location --request POST 'https://api-eu1.tatum.io/v3/nft/mint' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"tokenId": "1",
"to": "0x8cb76aed9c5e336ef961265c6079c14e9cd3d2ea",
"chain": "CELO",
"contractAddress": "0x1860Cf5A199892BC527A0698e7be08a7C6Bc6064",
"url": "https://my_token_data.com",
"fromPrivateKey": "0x4874827a55d87f2309c55b835af509e3427aa4d52321eeb49a2b93b5c0f8edfb",
"feeCurrency": "CUSD"
}'
Response
{
"txId": "0x35c8a88f194a62732b8ba3377a5f4e4801994976dbfbcad4c86b15a990a4b73f"
}

Transferring a specific ERC-721 token

To transfer tokens from the address where they were issued to another blockchain address, you can use the Transfer NFT token endpoint. You need the private key of the address where the tokens are located (the contract address from the first call where the initial supply is distributed).

Request
Response
Request
curl --location --request POST 'https://api-eu1.tatum.io/v3/nft/transaction' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"tokenId": "1",
"chain": "CELO",
"to": "0xfb99F8aE9b70A0C8Cd96aE665BBaf85A7E01a2ef",
"contractAddress": "0x1860Cf5A199892BC527A0698e7be08a7C6Bc6064",
"fromPrivateKey": "0x4874827a55d87f2309c55b835af509e3427aa4d52321eeb49a2b93b5c0f8edfb",
"feeCurrency": "CUSD"
}'
Response
{
"txId": "0x21ec859ec3d859b3cf47d0a99660e242af4f124f514996b042339d42d5a44d90"
}

Again, the result is a blockchain transaction with an ID.

Getting a list of tokens that belong to an address

If you want to display a list of tokens that someone possesses, you can use the Get NFT Account balance endpoint.

Request
Response
Request
curl --location --request GET 'https://api-eu1.tatum.io/v3/nft/balance/CELO/0x1860Cf5A199892BC527A0698e7be08a7C6Bc6064/0xfb99F8aE9b70A0C8Cd96aE665BBaf85A7E01a2ef' \
--header 'x-api-key: YOUR_API_KEY'
Response
{
"data": ["1"]
}

The response contains the token IDs of the NFTs at the specified address.

Obtaining metadata for a specific token

If you want to obtain a metadata URL for a token, you can use the Get NFT Token metadata endpoint.

Request
Response
Request
curl --location --request GET 'https://api-eu1.tatum.io/v3/nft/metadata/CELO/0x1860Cf5A199892BC527A0698e7be08a7C6Bc6064/1' \
--header 'x-api-key: YOUR_API_KEY'
Response
{
"data": "https://my_token_data.com"
}

Pretty simple, right? You only had to make three calls to Tatum to deploy your own token, issue a unique one, and transfer it. Another two for getting useful information. You don't have to install anything, learn Solidity, etc.

To find out more about the API calls we have just used, visit our API Reference.

Also, be sure to watch through our workshops on How to create NFT marketplaces:

Frontend and user journey:

Creating NFTs, working with metadata:

Working with ERC-1155 multi-tokens: