Burn Tokens
The burnTokens function permanently destroys tokens from a token account. This reduces the token supply and cannot be undone.
Usage
const signature = await connection.burnTokens({
mintAddress, // address of the token mint
owner, // owner of the tokens to burn
amount, // amount of tokens to burn (in base units)
});Parameters
mintAddress:Address- Address of the token mintowner:KeyPairSigner- Owner of the tokens to burn (must sign)amount:bigint- Amount of tokens to burn (in base units, adjusted for decimals)useTokenExtensions:boolean(optional) - Use Token Extensions (Token-2022) program instead of classic Token program (default: true)skipPreflight:boolean(optional) - Skip pre-flight transaction checks (default: true)maximumClientSideRetries:number(optional) - Number of retry attempts if the transaction fails (default: 0)abortSignal:AbortSignal | null(optional) - Signal to cancel the transaction (default: null)
Returns
Returns a Promise<string> - The transaction signature that can be used to look up the transaction.
Example
import { lamports, SOL } from "@solana/kit";
// Create a wallet and mint some tokens
const owner = await connection.createWallet({
airdropAmount: lamports(1n * SOL),
});
const mintAddress = await connection.createTokenMint({
mintAuthority: owner,
decimals: 9,
name: "My Token",
symbol: "TKN",
uri: "https://example.com/token.json",
});
// Mint 1000 tokens
await connection.mintTokens(mintAddress, owner, 1000n, owner.address);
// Burn 100 tokens
const signature = await connection.burnTokens({
mintAddress,
owner,
amount: 100n,
});
console.log(`Burned tokens: ${signature}`);Error Handling
The function will throw an error if:
- The token account doesn’t exist or has insufficient balance
- The owner doesn’t have permission to burn tokens from the account
- The mint address is invalid
- The owner lacks sufficient SOL to pay for the transaction
- The RPC connection fails
Notes
- Burning tokens permanently destroys them and reduces the total supply
- The amount is specified in base units (e.g., for a token with 9 decimals, 1 token = 1,000,000,000 base units)
- The function automatically retrieves the correct decimal places from the mint
- Supports both Token Extensions (Token-2022) and classic Token programs
Last updated on