Docs

useBurnToken

Hook for burning ERC20 tokens on a smart contract.

Available to use on smart contracts that implement the ERC20 standard.

Example

import {
useBurnToken,
useContract,
Web3Button,
} from "@thirdweb-dev/react";
function App() {
const { contract } = useContract(contractAddress);
const {
mutateAsync: burnToken,
isLoading,
error,
} = useBurnToken(contract);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
burnToken({
amount: "10", // Amount of tokens to burn
})
}
>
Burn Token
</Web3Button>
);
}

Parameters

Returns

A mutation object to burn tokens from the connected wallet

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

options

The mutation function takes an object as an argument with the following properties:

amount (required)

The amount of tokens to burn.

The wallet initiating this transaction must have at least this amount of tokens.