Skip to Content
TokenburnToken

burnToken

This function burns tokens from a token account.

Usage

page.tsx
import { useConnection, useWallet } from "@solana/wallet-adapter-react"; import { burnToken } from "@okito/sdk"; const {connection} = useConnection(); const wallet = useWallet(); const mint = "TOKEN_MINT_ADDRESS"; // The mint address of the token to burn const amount = BigInt(1000000); // Amount in raw token units const burnResult = await burnToken(connection, wallet, mint, amount, { enableLogging: true, // Detailed operation tracking enableSimulation: true, // Pre-flight transaction testing strictValidation: true, // Enhanced safety checks maxRetries: 3, // Automatic retry on failure timeoutMs: 60000, // 1-minute timeout confirmationStrategy: 'confirmed' });

Capabilities

Token burning permanently removes tokens and cannot be undone. The function includes guardrails, such as large-burn warnings and supply checks.

Parameters

NameTypeDefault
connection
Connection
Solana connection instance for blockchain interaction.
wallet
SignerWallet
The wallet instance with signing capabilities.
mint
string
The mint address of the token to burn.
amount
bigint | string | number
Amount in base token units.
config
BurnTokenConfig
See below for burn-specific options.
Defaults

BurnTokenConfig

NameTypeDefault
mint
string
The mint address of the token to burn.
amount
bigint | string | number
Amount in base token units.
Base Config
OperationConfig
Logging, retries, timeouts, simulation, and validation.
Defaults

Response

Returns OperationResult.

NameTypeDefault
success
boolean
Whether the burn succeeded.
transactionId
string
Signature of the transaction.
estimatedFee
number
Estimated fee in lamports.
confirmationTime
number
Total time in ms.
error
string
Error message if any.

Error Handling

The function provides comprehensive error handling with specific error codes:

  • WALLET_NOT_CONNECTED: Wallet is not properly connected
  • INSUFFICIENT_FUNDS: Insufficient token balance for burn
  • INVALID_TOKEN_DATA: Token data validation failed
  • NETWORK_ERROR: Network connectivity issues
  • TRANSACTION_FAILED: Transaction execution failed

Each error includes detailed context and recovery suggestions.

Last updated on