helius_get_token_account_balance
Retrieve the current balance of a specific token account on the Solana blockchain using the Helius API.
Instructions
Get the balance of a token account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tokenAddress | Yes | ||
| commitment | No |
Implementation Reference
- src/handlers/helius.ts:137-148 (handler)The main handler function that executes the tool: validates the token account address, calls the Helius RPC connection.getTokenAccountBalance method, and returns the formatted balance or error.export const getTokenAccountBalanceHandler = async (input: GetTokenAccountBalanceInput): Promise<ToolResultSchema> => { const tokenAddressResult = validatePublicKey(input.tokenAddress); if (!(tokenAddressResult instanceof PublicKey)) { return tokenAddressResult; } try { const tokenBalance = await (helius as any as Helius).connection.getTokenAccountBalance(tokenAddressResult, input.commitment); return createSuccessResponse(`Token balance: ${JSON.stringify(tokenBalance.value)}`); } catch (error) { return createErrorResponse(`Error getting token account balance: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools.ts:102-113 (schema)The tool definition including name, description, and inputSchema for validation.{ name: "helius_get_token_account_balance", description: "Get the balance of a token account", inputSchema: { type: "object", properties: { tokenAddress: { type: "string" }, commitment: { type: "string", enum: ["confirmed", "finalized", "processed"] } }, required: ["tokenAddress"] } },
- src/tools.ts:556-556 (registration)Registration of the tool name to its handler function in the handlers dictionary."helius_get_token_account_balance": getTokenAccountBalanceHandler,