EVM - Create a NFT Collection (SDK)
createNftCollection deploys an ERC-721 NFT collection for you, pays the gas from your Tatum plan, and transfers ownership to the owner address you set.
An NFT, or non-fungible token, is a type of cryptocurrency that represents a unique item or asset. Unlike regular cryptocurrencies such as Bitcoin or Ether, NFTs aren't interchangeable with other tokens of the same type but stand as unique tokens with their own specific value. They leverage blockchain technology to establish provenance and ownership.
An NFT collection is a group of NFTs, typically bound together by a common theme or brand. Each individual NFT within the collection is unique, but they are all part of the broader collection. Think of it like a collection of paintings from the same artist or a series of collectible toys.
Note : This function creates a collection for you using your Tatum Plan and transfers the ownership to you. Thus the gas cost is paid from the Tatum Plan.
In case you would like to create it directly from your wallet check the createNftCollection function in the MetaMask extension of the Wallet Provider submodule.
How to create NFT Collection (ERC-721 type) on the Ethereum network
The examples below deploy the collection on Ethereum Sepolia (testnet). For Ethereum mainnet, use Network.ETHEREUM in the SDK and ethereum-mainnet in the cURL request.
// yarn add @tatumio/tatum
import {TatumSDK, Network, Ethereum, ResponseDto} from '@tatumio/tatum'
const tatum = await TatumSDK.init<Ethereum>({network: Network.ETHEREUM_SEPOLIA, apiKey: '{YOUR_API_KEY}'})
const tx: ResponseDto<{txId: string}> = await tatum.nft.createNftCollection({
name: 'My NFT Collection',
symbol: 'MyNFT',
owner: '0x727ea45b2eb6abb2badd3dc7106d146e0dc0450d', // replace with your address
})
console.log(tx.data.txId)
// 0x8e564406701caab6258501c794f5c1eece380f673be99b561d626c3d8d81b202
// you can get created collection address using this RPC call
// once the deployment transaction is included in a block
const collectionAddress = await tatum.rpc.getContractAddress(tx.data.txId)
console.log(collectionAddress)
// 0x876977006988ce590e219f576077459a49c7318a
await tatum.destroy()// Install with: npm install @tatumio/tatum
const { TatumSDK, Network } = require("@tatumio/tatum");
(async () => {
const tatum = await TatumSDK.init({ network: Network.ETHEREUM_SEPOLIA, apiKey: '{YOUR_API_KEY}' });
try {
const tx = await tatum.nft.createNftCollection({
name: 'My NFT Collection',
symbol: 'MyNFT',
owner: '0x727ea45b2eb6abb2badd3dc7106d146e0dc0450d', // replace with your address
});
console.log(tx.data.txId);
// 0x8e564406701caab6258501c794f5c1eece380f673be99b561d626c3d8d81b202
// once the deployment transaction is included in a block
const collectionAddress = await tatum.rpc.getContractAddress(tx.data.txId);
console.log(collectionAddress);
// 0x876977006988ce590e219f576077459a49c7318a
} catch (error) {
console.error("Error creating NFT collection:", error);
} finally {
await tatum.destroy();
}
})();curl --location --request POST 'https://api.tatum.io/v4/contract/deploy' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data-raw '{
"contractType": "nft",
"chain": "ethereum-sepolia",
"name": "My NFT Collection",
"symbol": "MyNFT",
"owner": "0x727ea45b2eb6abb2badd3dc7106d146e0dc0450d"
}'Use Cases for NFT Collections
- Art: Artists can mint their artworks as NFTs and sell them directly to collectors. Each NFT represents a unique piece of art or a limited edition series.
- Collectibles: Virtual collectibles, such as CryptoPunks or NBA Top Shots, are often grouped into collections. Each unique item in the collection is an NFT.
- Virtual Real Estate and Goods: Platforms like Decentraland allow users to own and trade virtual land and assets as NFTs.
- Music and Entertainment: Musicians can mint their albums or songs as NFTs, providing a new way to monetize their work and connect with fans. Movies or show clips can also be tokenized as collectible NFTs.
- Identity and Certification: NFTs can be used to represent ownership or the achievement of something, such as completing a course or owning a specific domain name.
By creating an NFT collection using the Tatum SDK, you can easily mint, manage, and distribute NFTs on the blockchain. Whether you're an artist launching a new series of artwork, a game developer creating unique in-game items, or a brand creating digital collectibles, the ability to create an NFT collection offers exciting new possibilities for digital ownership and commerce.
Request interface
export interface CreateNftCollection {
/**
* Name of the NFT collection, e.g. Bored Ape Yacht Club
*/
name: string
/**
* Symbol of the NFT collection, e.g. BAYC
*/
symbol: string
/**
* Address of the NFT collection owner
*/
owner: string
/**
* Address of the NFT collection minter, this is optional and defaults to the owner address
*/
minter?: string
/**
* Optional base URI, which will be prepended to the token URI. If not specified, the token should be minted with the URI
*/
baseURI?: string
}Response interface
// createNftCollection returns ResponseDto<{txId: string}>
interface ResponseDto<T> {
/**
* Actual payload of the response
*/
data: T
/**
* Status of the response
*/
status: Status
/**
* In case of ERROR status, this field contains the error message and detailed description
*/
error?: ErrorWithMessage
}Supported blockchain networks
| Network | Support |
|---|---|
Ethereum / Ethereum Sepolia BNB Smart Chain / BNB Smart Chain Testnet Celo Polygon | ERC-721 NFT collections (BAYC,...) |
Updated 8 days ago