get_balance_ether
Check ETH balance for any Ethereum address on Arbitrum networks using this tool. Query wallet holdings to monitor funds across Arbitrum chains.
Instructions
Get balance of an address in ETH
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rpcUrl | No | The RPC URL of the chain (optional if default is set) | |
| address | Yes | Ethereum address to check balance for |
Implementation Reference
- src/index.ts:252-268 (handler)MCP tool handler for 'get_balance_ether': resolves RPC URL, instantiates EthereumAccountClient, calls getBalanceInEther on the provided address, formats response as text content.case "get_balance_ether": { const rpcUrl = await this.resolveRpcUrl( (args.rpcUrl as string) || (args.chainName as string) ); const ethereumAccountClient = new EthereumAccountClient(rpcUrl); const balanceEth = await ethereumAccountClient.getBalanceInEther( args.address as string ); return { content: [ { type: "text", text: `Balance: ${balanceEth} ETH`, }, ], }; }
- src/index.ts:962-980 (registration)Tool registration definition in getAvailableTools(): specifies name 'get_balance_ether', description, and input schema requiring 'address' (rpcUrl and chainName optional). Used for list tools response.{ name: "get_balance_ether", description: "Get balance of an address in ETH", 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"], }, },
- src/index.ts:965-979 (schema)Input schema definition for 'get_balance_ether' tool: object with optional rpcUrl/chainName and required address string.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"], },
- Primary helper implementation: getBalanceInEther(address) converts wei balance to human-readable ETH string, handling integer and decimal cases precisely.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+$/, ''); } }
- Supporting helper: getBalance(address) performs raw 'eth_getBalance' RPC call at latest block, returns wei hex string.async getBalance(address: string): Promise<string> { const balance = await this.makeRpcCall('eth_getBalance', [address, 'latest']); return balance; }