Skip to main content
Glama

get_balance

Retrieve native token balances (like ETH or MATIC) for any wallet address across EVM-compatible blockchain networks to monitor account holdings.

Instructions

Get the native token balance (ETH, MATIC, etc.) for an address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesThe wallet address or ENS name
networkNoNetwork name or chain ID. Defaults to Ethereum mainnet.

Implementation Reference

  • Primary registration of the 'get_balance' MCP tool. Includes inline Zod schema for input validation (address and optional network), description, and handler function that resolves the address via ENS if needed, fetches balance using services.getETHBalance, formats wei/ether, and returns structured JSON response or error.
    'get_balance', 'Get the native token balance (ETH, MATIC, etc.) for an address', { address: z .string() .describe( "The wallet address or ENS name (e.g., '0x1234...' or 'vitalik.eth') to check the balance for" ), network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', etc.) or chain ID. Supports all EVM-compatible networks. Defaults to Ethereum mainnet." ) }, async ({ address, network = 'ethereum' }) => { try { const balance = await services.getETHBalance(address, network); return { content: [ { type: 'text', text: JSON.stringify( { address, network, wei: balance.wei.toString(), ether: balance.ether }, null, 2 ) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching balance: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
  • Core handler logic for fetching native token (ETH) balance. Resolves ENS names to addresses, uses viem's public client to call getBalance, and formats the result into wei bigint and human-readable ether string.
    export async function getETHBalance( addressOrEns: string, network = 'ethereum' ): Promise<{ wei: bigint; ether: string }> { // Resolve ENS name to address if needed const address = await resolveAddress(addressOrEns, network); const client = getPublicClient(network); const balance = await client.getBalance({ address }); return { wei: balance, ether: formatEther(balance) }; }
  • Server initialization where registerEVMTools(server) is called, which registers the get_balance tool among other EVM tools.
    registerEVMResources(server); registerEVMTools(server); registerEVMPrompts(server);
  • Re-export of balance service functions (including getETHBalance) as 'services' namespace used by the tool handler.
    export * from './clients.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/chulanpro5/evm-mcp-server'

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