Skip to main content
Glama
dewanshparashar

Arbitrum MCP Server

get_balance

Check the wei balance of any Ethereum address on Arbitrum networks using RPC endpoints for monitoring and interaction.

Instructions

Get balance of an address in wei

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rpcUrlNoThe RPC URL of the chain (optional if default is set)
addressYesEthereum address to check balance for

Implementation Reference

  • MCP tool handler for 'get_balance': resolves RPC URL using chainName/rpcUrl, creates EthereumAccountClient instance, calls getBalance(address), formats and returns balance in wei as text content.
    case "get_balance": { const rpcUrl = await this.resolveRpcUrl( (args.rpcUrl as string) || (args.chainName as string) ); const ethereumAccountClient = new EthereumAccountClient(rpcUrl); const balance = await ethereumAccountClient.getBalance( args.address as string ); return { content: [ { type: "text", text: `Balance: ${balance} wei`, }, ], }; }
  • src/index.ts:944-960 (registration)
    Tool registration definition in getAvailableTools(): specifies name, description, and inputSchema for the 'get_balance' tool.
    name: "get_balance", description: "Get balance of an address in wei", inputSchema: { type: "object" as const, properties: { rpcUrl: { type: "string", description: "The RPC URL of the chain (optional if default is set)", }, address: { type: "string", description: "Ethereum address to check balance for", }, }, required: ["address"], },
  • Helper function EthereumAccountClient.getBalance(): performs the 'eth_getBalance' RPC call with address and 'latest' block tag, returns raw balance in wei.
    async getBalance(address: string): Promise<string> { const balance = await this.makeRpcCall('eth_getBalance', [address, 'latest']); return balance; }
  • Related helper EthereumAccountClient.getBalanceInEther(): converts wei balance to ETH with decimal handling (used by separate get_balance_ether tool).
    async getBalanceInEther(address: string): Promise<string> { const weiBalance = await this.getBalance(address); const wei = BigInt(weiBalance); const ether = wei / BigInt('1000000000000000000'); const remainder = wei % BigInt('1000000000000000000'); if (remainder === BigInt(0)) { return ether.toString(); } else { const etherDecimal = Number(wei) / 1e18; return etherDecimal.toFixed(6).replace(/\.?0+$/, ''); } }
  • Underlying makeRpcCall method: handles all RPC calls to the provider, used by getBalance.
    private async makeRpcCall(method: string, params: any[]): Promise<any> { try { const requestBody = { jsonrpc: '2.0', id: Date.now(), method, params, }; console.error(`Making RPC call to ${this.rpcUrl}: ${method}`); const response = await fetch(this.rpcUrl, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(requestBody), }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json(); if (data.error) { throw new Error(`RPC Error: ${data.error.message}`); } return data.result; } catch (error) { console.error(`RPC call failed for ${method} on ${this.rpcUrl}:`, error); if (error instanceof Error) { throw error; } else { throw new Error(`Unknown error during RPC call: ${String(error)}`); } } }

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/dewanshparashar/arbitrum-mcp'

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