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 | 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. |
|
BurnTokenConfig
Name | Type | Default |
---|---|---|
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. |
|
Response
Returns OperationResult.
Name | Type | Default |
---|---|---|
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 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