Skip to main content
Glama

burn_tokens

Burn tokens from a Solana wallet to permanently remove them from circulation, reducing token supply by specifying wallet name, token mint address, and amount.

Instructions

Burn tokens from a wallet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletNameYesName of the wallet to burn tokens from
tokenMintYesToken mint address
amountYesAmount of tokens to burn (in token units)

Implementation Reference

  • The handler function that executes the burn_tokens tool. It retrieves the wallet, calculates the raw token amount based on mint decimals, gets the associated token account, and calls the Solana SPL `burn` instruction to burn the specified amount of tokens.
    async function handleBurnTokens(args: any) {
      const { walletName, tokenMint, amount } = args;
    
      const wallet = wallets.get(walletName);
      if (!wallet) {
        throw new Error(`Wallet '${walletName}' not found`);
      }
    
      ensureConnection();
      const tokenMintPubkey = new PublicKey(tokenMint);
    
      const mintInfo = await getMint(connection, tokenMintPubkey);
      const rawAmount = BigInt(Math.floor(amount * Math.pow(10, mintInfo.decimals)));
    
      const tokenAccount = await getAssociatedTokenAddress(
        tokenMintPubkey,
        wallet.keypair.publicKey
      );
    
      const signature = await burn(
        connection,
        wallet.keypair,
        tokenAccount,
        tokenMintPubkey,
        wallet.keypair,
        rawAmount
      );
    
      return {
        success: true,
        signature,
        amount,
        tokenMint: tokenMint,
        explorerUrl: `https://explorer.solana.com/tx/${signature}?cluster=${currentNetwork}`
      };
    }
  • Input schema definition for the burn_tokens tool, specifying the required parameters: walletName, tokenMint, and amount.
    inputSchema: {
      type: "object",
      properties: {
        walletName: {
          type: "string",
          description: "Name of the wallet to burn tokens from"
        },
        tokenMint: {
          type: "string",
          description: "Token mint address"
        },
        amount: {
          type: "number",
          description: "Amount of tokens to burn (in token units)"
        }
      },
      required: ["walletName", "tokenMint", "amount"]
    }
  • src/index.ts:351-372 (registration)
    Tool registration in the `tools` array, which is returned by the ListToolsRequestHandler. Includes name, description, and input schema.
    {
      name: "burn_tokens",
      description: "Burn tokens from a wallet",
      inputSchema: {
        type: "object",
        properties: {
          walletName: {
            type: "string",
            description: "Name of the wallet to burn tokens from"
          },
          tokenMint: {
            type: "string",
            description: "Token mint address"
          },
          amount: {
            type: "number",
            description: "Amount of tokens to burn (in token units)"
          }
        },
        required: ["walletName", "tokenMint", "amount"]
      }
    },
  • src/index.ts:1336-1337 (registration)
    Dispatch registration in the switch statement of the CallToolRequestHandler, routing burn_tokens calls to the handleBurnTokens function.
    case "burn_tokens":
      result = await handleBurnTokens(args);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ExpertVagabond/solana-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server