helius_get_token_account_balance
Retrieve the balance of any Solana token account by providing the token address. Optionally set commitment for data confirmation.
Instructions
Get the balance of a token account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tokenAddress | Yes | ||
| commitment | No |
Implementation Reference
- src/handlers/helius.ts:137-148 (handler)The main handler function for the 'helius_get_token_account_balance' tool. It validates the token address, calls Helius connection.getTokenAccountBalance, and returns the token balance.
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/handlers/helius.types.ts:65-68 (schema)Input type definition for the token account balance tool: requires tokenAddress string, optional commitment.
export type GetTokenAccountBalanceInput = { tokenAddress: string; commitment?: "confirmed" | "finalized" | "processed"; } - src/handlers/helius.types.ts:70-75 (schema)Output type definition for the token account balance tool: amount, decimals, uiAmount, uiAmountString.
export type GetTokenAccountBalanceOutput = { amount: string; decimals: number; uiAmount: number; uiAmountString: string; } - src/tools.ts:102-113 (registration)Tool registration with name, description, and inputSchema for 'helius_get_token_account_balance'.
{ 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)Handler mapping: maps the tool name 'helius_get_token_account_balance' to the getTokenAccountBalanceHandler function.
"helius_get_token_account_balance": getTokenAccountBalanceHandler,