Skip to main content
Glama

helius_get_balance

Retrieve the Solana wallet balance for a specified public key using the Helius API. Supports querying confirmed, finalized, or processed transaction states.

Instructions

Get the balance of a Solana address

Input Schema

NameRequiredDescriptionDefault
commitmentNo
publicKeyYes

Input Schema (JSON Schema)

{ "properties": { "commitment": { "enum": [ "confirmed", "finalized", "processed" ], "type": "string" }, "publicKey": { "type": "string" } }, "required": [ "publicKey" ], "type": "object" }

Implementation Reference

  • Main handler function implementing the helius_get_balance tool logic using Helius SDK to fetch account balance.
    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)}`); } }
  • Input schema definition for the helius_get_balance tool in the tools registry.
    { 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)
    Maps the tool name 'helius_get_balance' to its handler function getBalanceHandler in the handlers dictionary.
    "helius_get_balance": getBalanceHandler,
  • TypeScript type definition for the input of getBalanceHandler, matching the tool's inputSchema.
    export type GetBalanceInput = { publicKey: string; commitment?: "confirmed" | "finalized" | "processed"; }
  • Imports helper functions used in the handler: validatePublicKey for input validation, createSuccessResponse and createErrorResponse for output formatting.
    import { createErrorResponse, createSuccessResponse, validatePublicKey } from "./utils.js";

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/dcSpark/mcp-server-helius'

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