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
| Name | Type | Default |
|---|---|---|
connection | ConnectionSolana connection instance for blockchain interaction. | |
wallet | SignerWalletThe wallet instance with signing capabilities. | |
mint | stringThe mint address of the token to burn. | |
amount | bigint | string | numberAmount in base token units. | |
config | BurnTokenConfigSee below for burn-specific options. | |
BurnTokenConfig
| Name | Type | Default |
|---|---|---|
mint | stringThe mint address of the token to burn. | |
amount | bigint | string | numberAmount in base token units. | |
Base Config | OperationConfigLogging, retries, timeouts, simulation, and validation. | |
Response
Returns OperationResult.
| Name | Type | Default |
|---|---|---|
success | booleanWhether the burn succeeded. | |
transactionId | stringSignature of the transaction. | |
estimatedFee | numberEstimated fee in lamports. | |
confirmationTime | numberTotal time in ms. | |
error | stringError message if any. | |
Error Handling
The function provides comprehensive error handling with specific error codes:
WALLET_NOT_CONNECTED: Wallet is not properly connectedINSUFFICIENT_FUNDS: Insufficient token balance for burnINVALID_TOKEN_DATA: Token data validation failedNETWORK_ERROR: Network connectivity issuesTRANSACTION_FAILED: Transaction execution failed
Each error includes detailed context and recovery suggestions.
Last updated on