Skip to main content

ERC721 Standard Features

Using ERC721 features lets you add standard ERC721 compliant NFTfunctionality to your contracts. These interfaces can give your contract simple read-only functionality as well as more complex features like NFT minting and transfers.

We support a number of different ERC721 features on your contracts that enable different SDK and dashboard functionality. Let's explore all the options below!

ERC721

The most standard ERC721 interface, which is often considered the default and is implemented by most ERC721 tokens, is the EIP-721 standard.

If your contract, implements all the functions in this standard, you will get support for all of the following functions in the SDK.

Setup

You can get an initial instance for your contract with the following code:

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

balanceOf

Get NFT Balance

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

get

Get a single NFT Metadata

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

transfer

Transfer a single NFT

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

Extensions

In addition to the standard ERC721 interface, we also support the following additional ERC721 features which you can add onto your contract ERC721 contract.

info

In order to use these features, the contract must also implement the standard ERC721 interface as well.

ERC721Mintable

The ERC721Mintable interface enables you to add minting functionality to your NFTs. You can add this interface to your contract by implementing all of the functions in the IMintableER721 interface as shown below:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@thirdweb-dev/contracts/ThirdwebContract.sol";
import "@thirdweb-dev/contracts/feature/interface/IMintableERC721.sol";

// We add the interface to the contract
contract MyCustomContract is ThirdwebContract, IMintableERC721 {

// Implement functions here
function mintTo(address to, string calldata uri) external returns (uint256) {

}
}

If your contract, implements all the functions in this standard, you will get support for the following functions in the SDK.

Setup
const contract = await sdk.getContract("{{contract_address}}");
await contract.nft.mint.to(walletAddress, nftMetadata);
View in Javascript SDK Documentation

to

Mint a unique 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.nft.mint.to(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

ERC721BatchMintable

The ERC721BatchMintable interface enables you to add batch minting functionality to your tokens. You can add this interface to your contract by implementing all of the functions in the IMintableERC721 and IMulticall interfaces as shown below:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@thirdweb-dev/contracts/ThirdwebContract.sol";
import "@thirdweb-dev/contracts/feature/interface/IMintableERC721.sol";
import "@thirdweb-dev/contracts/feature/interface/IMulticall.sol";

// We add the interface to the contract
contract MyCustomContract is ThirdwebContract, IMintableERC721, IMulticall {

// Implement your functions below
function mintTo(address to, string calldata uri) external returns (uint256) {

}

function multicall(bytes[] data) external nonpayable returns (bytes[] results) {

}
}

If your contract, implements all the functions in this standard, you will get support for the following functions in the SDK.

Setup
const contract = await sdk.getContract("{{contract_address}}");
await contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]);
View in Javascript SDK Documentation

to

Mint Many unique NFTs

// 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.mint.batch.to(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

ERC721Supply

The ERC721Supply interface enables you to add NFT supply functionality to your NFTs. You can add this interface to your contract by implementing all of the functions in the IERC721Supply interface as shown below:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@thirdweb-dev/contracts/ThirdwebContract.sol";

// We add the interface to the contract
contract MyCustomContract is ThirdwebContract {

// Implement your functions below
function totalSupply() external view returns (uint256) {

}
}

If your contract implements all the functions in this standard, you will get support for the following SDK interface.

const contract = await sdk.getContract("{{contract_address}}");
const nfts = await contract.nft.query.all();
View in Javascript SDK Documentation

all

Get All Minted NFTs

const nfts = await contract.nft.query.all();
View in Javascript SDK Documentation

ERC721Enumerable

The ERC721Enumerable interface enables you to add enumerable functionality to your NFTs. You can add this interface to your contract by implementing all of the functions in the IERC721Enumerable interface as shown below:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@thirdweb-dev/contracts/ThirdwebContract.sol";

// We add the interface to the contract
contract MyCustomContract is ThirdwebContract {

// Implement your functions below
function tokenByIndex(uint256 _index) external view returns (uint256) {

}
}

If your contract implements all the functions in this standard, you will get support for the following SDK interface.

const contract = await sdk.getContract("{{contract_address}}");
const walletAddress = "0x...";
const ownedNFTs = await contract.nft.query.owned.all(walletAddress);
View in Javascript SDK Documentation

all

Get Owned NFTs

// Address of the wallet to get the NFTs of
const address = "{{wallet_address}}";
const nfts = await contract.nft.query.owned.all(address);
View in Javascript SDK Documentation