Skip to main content
Glama

approve_delegate

Authorize a delegate to transfer specific tokens from your Solana wallet by setting permissions and maximum transfer amounts.

Instructions

Approve a delegate to transfer tokens on your behalf

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletNameYesName of the wallet that owns the tokens
tokenMintYesToken mint address
delegateAddressYesAddress of the delegate
amountYesMaximum amount delegate can transfer

Implementation Reference

  • The core handler function that approves a delegate for transferring up to a specified amount of tokens from the owner's token account using the SPL Token program's approve instruction.
    async function handleApproveDelegate(args: any) { const { walletName, tokenMint, delegateAddress, amount } = args; const wallet = wallets.get(walletName); if (!wallet) { throw new Error(`Wallet '${walletName}' not found`); } ensureConnection(); const tokenMintPubkey = new PublicKey(tokenMint); const delegatePubkey = new PublicKey(delegateAddress); 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 approve( connection, wallet.keypair, tokenAccount, delegatePubkey, wallet.keypair, rawAmount ); return { success: true, signature, delegate: delegateAddress, amount, explorerUrl: `https://explorer.solana.com/tx/${signature}?cluster=${currentNetwork}` }; }
  • Input schema definition for the approve_delegate tool, specifying parameters for wallet, token mint, delegate, and amount.
    { name: "approve_delegate", description: "Approve a delegate to transfer tokens on your behalf", inputSchema: { type: "object", properties: { walletName: { type: "string", description: "Name of the wallet that owns the tokens" }, tokenMint: { type: "string", description: "Token mint address" }, delegateAddress: { type: "string", description: "Address of the delegate" }, amount: { type: "number", description: "Maximum amount delegate can transfer" } }, required: ["walletName", "tokenMint", "delegateAddress", "amount"] } },
  • src/index.ts:1354-1356 (registration)
    Switch case in the main CallToolRequestSchema handler that registers and dispatches to the approve_delegate handler function.
    case "approve_delegate": result = await handleApproveDelegate(args); break;

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