useBurnNFT

Hook for burning a NFT on a smart contract.

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

Example

import {
useBurnNFT,
useContract,
Web3Button,
} from "@thirdweb-dev/react";
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>
);
}
function useBurnNFT(
contract: RequiredParam<TContract>,
): UseMutationResult<
Omit<{}, "data">,
unknown,
unknown
>;

Parameters

Instance of a NFTContract

Type

let contract: RequiredParam<TContract>;

Returns

let returnType: UseMutationResult<
Omit<{}, "data">,
unknown,
unknown
>;

Mutation object that to burn an NFT token from the connected wallet

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

options

The mutation function takes an object with the following properties:

tokenId

The token ID of the NFT you want to burn.

amount (optional)

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

Defaults value is 1