helius_get_balance
Retrieve the current SOL balance for any Solana wallet address using the Helius API.
Instructions
Get the balance of a Solana address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| publicKey | Yes | ||
| commitment | No |
Implementation Reference
- src/handlers/helius.ts:47-62 (handler)The getBalanceHandler function implements the core logic for the 'helius_get_balance' tool. It validates the public key, fetches the balance using the Helius connection, and formats the response.export const getBalanceHandler = async (input: GetBalanceInput): Promise<ToolResultSchema> => { try { // Validate the public key is a valid format const publicKey = validatePublicKey(input.publicKey); if (!(publicKey instanceof PublicKey)) { return publicKey; } // Remove the test mode check since we want to use the mock implementation const balance = await (helius as any as Helius).connection.getBalance(publicKey, input.commitment); return createSuccessResponse(`Balance: ${balance} lamports (${balance / LAMPORTS_PER_SOL} SOL)`); } catch (error) { return createErrorResponse(`Error getting balance: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools.ts:33-44 (schema)The input schema definition for the 'helius_get_balance' tool, specifying the expected parameters: publicKey (required) and optional commitment level.{ name: "helius_get_balance", description: "Get the balance of a Solana address", inputSchema: { type: "object", properties: { publicKey: { type: "string" }, commitment: { type: "string", enum: ["confirmed", "finalized", "processed"] } }, required: ["publicKey"] } },
- src/tools.ts:550-550 (registration)Registration of the 'helius_get_balance' tool, mapping the tool name to its handler function getBalanceHandler in the handlers dictionary."helius_get_balance": getBalanceHandler,