Skip to main content

useBurnNFT

Hook for burning a NFT on a smart contract.

Available to use on smart contracts that implement the ERC721 or ERC1155 standard.

import { useBurnNFT } from "@thirdweb-dev/react";

const { mutateAsync: burnNft, isLoading, error } = useBurnNFT(contract);

Usage

Provide your NFT collection contract as the argument.

import { useBurnNFT, useContract, Web3Button } from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";
// The tokenId of the NFT you want to burn
const tokenIdToBurn = "{{tokenId}}}}";
const amount = 1;

function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync: burnNft, isLoading, error } = useBurnNFT(contract);

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
burnNft({
tokenId: tokenIdToBurn,
amount: amount,
})
}
>
Burn NFT
</Web3Button>
);
}

Configuration

tokenId

tokenId (required)

The token ID of the NFT you want to burn.

import { useBurnNFT, useContract, Web3Button } from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";
// The tokenId of the NFT you want to burn
const tokenIdToBurn = "{{tokenId}}}}";

function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync: burnNft, isLoading, error } = useBurnNFT(contract);

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
burnNft({
tokenId: tokenIdToBurn,
amount: 1,
})
}
>
Burn NFT
</Web3Button>
);
}
amount

amount (optional)

When using ERC1155 NFTs, you can specify the quantity you want to burn.

Defaults value is 1.

import { useBurnNFT, useContract, Web3Button } from "@thirdweb-dev/react";

// Your smart contract address
const contractAddress = "{{contract_address}}";
// The tokenId of the NFT you want to burn
const tokenIdToBurn = "{{tokenId}}}}";
const amount = 1;

function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync: burnNft, isLoading, error } = useBurnNFT(contract);

return (
<Web3Button
contractAddress={contractAddress}
action={() =>
burnNft({
tokenId: tokenIdToBurn,
amount: amount,
})
}
>
Burn NFT
</Web3Button>
);
}