Skip to main content

useBurnToken

Hook for burning ERC20 tokens on a smart contract.

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

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

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

Usage

Provide your token contract as the argument.

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

// Your smart contract address
const contractAddress = "{{contract_address}}";

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>
);
}

Configuration

amount (required)

amount (required)

The amount of tokens to burn.

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

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

// Your smart contract address
const contractAddress = "{{contract_address}}";

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>
);
}