Skip to main content

Edition

Learn how to interact with your Edition contract in the SDK.

Create an Edition Contract

Deploys a new Edition contract
const sdk = useSDK();

const contractAddress = await sdk.deployer.deployEdition({
name: "My Edition",
primary_sale_recipient: "your-address",
});
View in React SDK Documentation

Getting the contract in your application

To start using your Edition contract inside your application, you'll need to use its contract address. You can get the contract address from the dashboard.

import { useContract } from '@thirdweb-dev/react'

export default function Component() {
const { contract } = useContract("<YOUR-CONTRACT-ADDRESS>", "edition")

// Now you can use the edition contract in the rest of the component
}

Setting Royalty Fees

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

Minting NFTs

Mint One NFT

Mint an NFT with a limited supply
const Component = () => {
const { contract } = useContract("{{contract_address}}");
const {
mutate: mintNft,
isLoading,
error,
} = useMintNFT(contract);

if (error) {
console.error("failed to mint NFT", error);
}

return (
<button
disabled={isLoading}
onClick={() => mintNft({ name: "My awesome NFT!", to: "{{wallet_address}}" })}
>
Mint!
</button>
);
};
View in React SDK Documentation

Mint Many NFTs (Batch Mint)

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.mintBatchTo(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 React SDK Documentation

Airdrop NFTs

Viewing NFTs

One NFT

Get a single NFT
const tokenId = 0; // the tokenId to look up
const { data: nft, isLoading, error } = useNFT(contract, tokenId);
View in React SDK Documentation

All NFTs

Get all NFTs
const { data: nfts, isLoading, error } = useNFTs(contract, { start: 0, count: 100 });
View in React SDK Documentation

NFTs owned by a specific wallet

Get all NFTs owned by a specific wallet
const { data: ownedNFTs, isLoading, error } = useOwnedNFTs(contract, "{{wallet_address}}");
View in React SDK Documentation

Amount of tokens owned by a specific wallet

Get NFT Balance
const { data: ownerBalance, isLoading, error } = useNFTBalance(contract, "{{wallet_address}}");
// for ERC1155 contracts, you can also pass a tokenId
const tokenId = 0;
const { data: ownerBalance, isLoading, error } = useNFTBalance(contract, "{{wallet_address}}", tokenId);
View in React SDK Documentation

Transferring NFTs

Burning NFTs

Burn a specified amount of a NFT
const result = await contract.burnTokens(tokenId, amount);
View in React SDK Documentation