Skip to main content
Glama

get_balance

Retrieve native token balance for a wallet on any blockchain, displaying amounts in both raw units and human-readable format to monitor asset holdings.

Instructions

Get the native token balance for a wallet on a specific chain. Returns balance in both wei (or lamports for Solana) and human-readable format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
wallet_idYesWallet ID
chain_idNoChain ID to check (defaults to wallet's default chain)

Implementation Reference

  • The 'get_balance' tool implementation. This is the complete registration including the tool name, description, Zod schema for input validation (wallet_id and optional chain_id), and the async handler function that calls the API endpoint /wallets/${wallet_id}/balance to retrieve native token balances.
    // ─── Tool: get_balance ───────────────────────────────────────────
    
    server.tool(
      'get_balance',
      'Get the native token balance for a wallet on a specific chain. ' +
        'Returns balance in both wei (or lamports for Solana) and human-readable format.',
      {
        wallet_id: z.number().int().describe('Wallet ID'),
        chain_id: z.number().int().optional().describe('Chain ID to check (defaults to wallet\'s default chain)'),
      },
      async ({ wallet_id, chain_id }) => {
        const params = chain_id ? `?chain_id=${chain_id}` : '';
        const data = await api(`/wallets/${wallet_id}/balance${params}`);
        return jsonResponse(data);
      },
    );

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/hifriendbot/agentwallet-mcp'

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