Skip to main content

ERC1155 Standard Functionality

Using ERC1155 features lets you add standard ERC1155 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 ERC1155 features on your contracts that enable different SDK and dashboard functionality. Let's explore all the options below!

ERC1155

The most standard ERC1155 interface, which is often considered the default and is implemented by most ERC1155 tokens, is the EIP-1155 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.edition.transfer(walletAddress, tokenId, quantity);
View in Javascript SDK Documentation

airdrop

Airdrop multiple NFTs

// The token ID of the NFT you want to airdrop
const tokenId = "0";
// Array of objects of addresses and quantities to airdrop NFTs to
const addresses = [
{
address: "0x...",
quantity: 2,
},
{
address: "0x...",
quantity: 3,
},
];
await contract.airdrop(tokenId, addresses);

// You can also pass an array of addresses, it will airdrop 1 NFT per address
const tokenId = "0";
const addresses = [
"0x...", "0x...", "0x...",
]
await contract.airdrop(tokenId, addresses);
View in Javascript SDK Documentation

balanceOf

Get NFT Balance

// Address of the wallet to check NFT balance
const walletAddress = "{{wallet_address}}";
const tokenId = 0; // Id of the NFT to check
const balance = await contract.balanceOf(walletAddress, tokenId);
View in Javascript SDK Documentation

get

Get a single NFT Metadata

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

transfer

Transfer a single NFT

// Address of the wallet you want to send the NFT to
const toAddress = "{{wallet_address}}";
const tokenId = "0"; // The token ID of the NFT you want to send
const amount = 3; // How many copies of the NFTs to transfer
await contract.transfer(toAddress, tokenId, amount);
View in Javascript SDK Documentation

Extensions

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

info

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

ERC155Mintable

The ERC155Mintable 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 IMintableER155 interface as shown below:

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

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

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

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

}
}

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

Setup

ERC1155BatchMintable

The ERC1155BatchMintable 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 IMintableERC1155 and IMulticall interfaces as shown below:

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

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

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

// Implement your functions below
function mintTo(address to, uint256 tokenId, string calladata uri, uint256 amount) external override {

}

function multicall(bytes[] data) external override returns (bytes[] results) {
// you can use any standard multicall implementation here
}
}

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.edition.mint.batch.to(walletAddress, [nftMetadataWithSupply1, nftMetadataWithSupply2, ...]);
View in Javascript SDK Documentation

to

Mint Many NFTs with limited supplies

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

// Custom metadata and supplies of your NFTs
const metadataWithSupply = [{
supply: 50, // The number of this NFT you want to mint
metadata: {
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
},
}, {
supply: 100,
metadata: {
name: "Cool NFT #2",
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.edition.mint.batch.to(toAddress, metadataWithSupply);
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

ERC1155Enumerable

The ERC1155Enumerable interface enables you to easily list all NFTs in your contract. You can add this interface to your contract by implementing all of the functions in the IERC1155Enumerable interface as shown below:

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

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

// Implement your function below
function nextTokenIdToMint() 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.edition.query.all();
View in Javascript SDK Documentation

all

Get All NFTs

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

owned

Get Owned NFTs

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