Skip to main content

NFT Collection

thirdweb's NFT Collection contract is a 1-of-1 or 1-of-many NFT Collection, that follows the ERC721 Standard.

The NFT Collection contract is suitable for when you want to have a collection of NFTs, but not "drop" or "release" them for your community to claim.

Unlike the NFT Drop contract, the NFT Collection contract does not lazy mint your NFTs. Instead, NFTs are minted immediately when they are added to the collection.

This means you can still transfer the NFTs or sell them on a Marketplace, and perform any other actions you would expect to do with a NFT.

You could use the NFT Collection contract to:

  • Create a 1-of-many collection of your photography
  • Create a 1-of-1 NFT that provides special utility
  • Mint your artwork as NFTs and then sell them on a Marketplace
  • Create a community-made NFT collection

Create an NFT Collection Contract

Learn how to create any of thirdweb's pre-built contracts in the Deploying Contracts page.

Getting the contract in your application

To start using your NFT Collection contract inside your application, you'll need to use it's contract address. You can get the contract address from the dashboard.

import { ThirdwebSDK } from "@thirdweb-dev/sdk";

const sdk = new ThirdwebSDK("rinkeby");
const contract = sdk.getNFTCollection("{{contract_address}}");

Setting Royalty Fees

Royalty fees are fees you earn on secondary sales of your NFTs. For example, if you sell an NFT on the marketplace, and it is then sold again to another user, you will earn a royalty fee.

Using the dashboard

From the dashboard, in the Settings tab you can set the royalty percentage and the address that should receive the revenue from royalties earned from secondary sales of the assets.

Configuring Royalties on the Dashboard

Using the thirdweb SDK

// royalties on the whole contract
contract.royalty.setDefaultRoyaltyInfo({
seller_fee_basis_points: 100, // 1%
fee_recipient: "0x..."
});
// override royalty for a particular token
contract.royalty.setTokenRoyaltyInfo(tokenId, {
seller_fee_basis_points: 500, // 5%
fee_recipient: "0x..."
});
View in Javascript SDK Documentation

Minting NFTs

With an NFT Collection contract, you choose which wallet addresses are able to mint NFTs into your collection.

By default, only you (the smart contract owner) are able to mint NFTs into the collection.

You can specify which wallets can mint in the Permissions tab of your NFT Collection, under the Creator section.

Configuring Royalties on the Dashboard

For more advanced use-cases, such as creating a community-made collection, you can use signature-based minting.

Using the dashboard

For a more in-depth guide on how to create an NFT Collection, check out our guide here Minting an NFT.

Using the thirdweb SDK

Mint One NFT

// Address of the wallet you want to mint the NFT to
const walletAddress = "{{wallet_address}}";

// Custom metadata of the NFT, note that you can fully customize this metadata with other properties.
const metadata = {
name: "Cool NFT",
description: "This is a cool NFT",
image: fs.readFileSync("path/to/image.png"), // This can be an image url or file
};

const tx = await contract.mintTo(walletAddress, metadata);
const receipt = tx.receipt; // the transaction receipt
const tokenId = tx.id; // the id of the NFT minted
const nft = await tx.data(); // (optional) fetch details of minted NFT
View in Javascript SDK Documentation

Mint Many NFTs (Batch Mint)

// Address of the wallet you want to mint the NFT to
const walletAddress = "{{wallet_address}}";

// Custom metadata of the NFTs you want to mint.
const metadatas = [{
name: "Cool NFT #1",
description: "This is a cool NFT",
image: fs.readFileSync("path/to/image.png"), // This can be an image url or file
}, {
name: "Cool NFT #2",
description: "This is a cool NFT",
image: fs.readFileSync("path/to/other/image.png"),
}];

const tx = await contract.mintBatchTo(walletAddress, metadatas);
const receipt = tx[0].receipt; // same transaction receipt for all minted NFTs
const firstTokenId = tx[0].id; // token id of the first minted NFT
const firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT
View in Javascript SDK Documentation

Viewing NFTs

Our SDKs provide helpful ways to view the NFTs in your collection.

One NFT

const tokenId = 0;
const nft = await contract.nft.get(tokenId);
View in Javascript SDK Documentation

All NFTs

const nfts = await contract.getAll();
console.log(nfts);
View in Javascript SDK Documentation

NFTs owned by a specific wallet

// Address of the wallet to get the NFTs of
const address = "{{wallet_address}}";
const nfts = await contract.getOwned(address);
console.log(nfts);
View in Javascript SDK Documentation

Amount of tokens owned by a specific wallet

const walletAddress = "{{wallet_address}}";
const balance = await contract.nft.balanceOf(walletAddress);
console.log(balance);
View in Javascript SDK Documentation

Transferring NFTs

You can transfer NFTs from one wallet to another.

const walletAddress = "{{wallet_address}}";
const tokenId = 0;
await contract.nft.transfer(walletAddress, tokenId);
View in Javascript SDK Documentation

Burning NFTs

Burning is the process of removing the token from circulation by sending it to an inaccessible address. It does not delete the token from the blockchain.

Using the dashboard

Burning Claimed NFTs on Dashboard

Using the SDK

const result = await contract.burn(tokenId);
View in Javascript SDK Documentation