Skip to main content
Glama

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
NameRequiredDescriptionDefault
publicKeyYes
commitmentNo

Implementation Reference

  • 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)}`); } }
  • 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,

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