Skip to main content
Glama
buildwithgrove

Grove's MCP Server for Pocket Network

compare_balances

Compare native token balances for any address across multiple EVM blockchain networks to analyze cross-chain holdings and distribution patterns.

Instructions

Compare native token balance for an address across multiple EVM chains

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesAddress to check
blockchainsNoList of blockchain names (optional, defaults to all EVM chains)
networkNoNetwork type (defaults to mainnet)

Implementation Reference

  • Core tool implementation: Fetches native token (ETH-like) balances for the given address across specified EVM chains using eth_getBalance RPC calls, converts to ETH decimals, aggregates total and counts non-zero balances.
    async compareBalances( address: string, blockchains?: string[], network: 'mainnet' | 'testnet' = 'mainnet' ): Promise<EndpointResponse> { try { // Get all EVM chains if not specified const chainsToCheck = blockchains || this.getEVMChains(); const results = await Promise.all( chainsToCheck.map(async (blockchain) => { const service = this.blockchainService.getServiceByBlockchain(blockchain, network); if (!service) { return { blockchain, error: 'Service not found', balance: null }; } const result = await this.blockchainService.callRPCMethod( service.id, 'eth_getBalance', [address, 'latest'] ); if (result.success && result.data) { const weiBalance = BigInt(result.data); const ethBalance = Number(weiBalance) / 1e18; return { blockchain, balance: ethBalance, balanceWei: weiBalance.toString(), balanceHex: result.data, }; } return { blockchain, error: result.error, balance: null }; }) ); const totalBalance = results .filter(r => r.balance !== null) .reduce((sum, r) => sum + (r.balance || 0), 0); return { success: true, data: { address, balances: results, totalBalance, chainsWithBalance: results.filter(r => r.balance && r.balance > 0).length, }, metadata: { timestamp: new Date().toISOString(), endpoint: 'multi-chain', }, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to compare balances', }; } }
  • MCP tool execution handler: Extracts arguments from tool call, invokes AdvancedBlockchainService.compareBalances, and returns formatted MCP response (JSON text content or error).
    case 'compare_balances': { const address = args?.address as string; const blockchains = args?.blockchains as string[] | undefined; const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet'; const result = await advancedBlockchain.compareBalances(address, blockchains, network); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
  • Input JSON Schema: Validates tool parameters - address (required string), blockchains (optional string array), network (optional enum: mainnet/testnet).
    inputSchema: { type: 'object', properties: { address: { type: 'string', description: 'Address to check', }, blockchains: { type: 'array', items: { type: 'string' }, description: 'List of blockchain names (optional, defaults to all EVM chains)', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['address'], },
  • Tool registration: Defines the 'compare_balances' tool with name, description, and input schema for MCP server registration via registerMultichainHandlers.
    { name: 'compare_balances', description: 'Compare native token balance for an address across multiple EVM chains', inputSchema: { type: 'object', properties: { address: { type: 'string', description: 'Address to check', }, blockchains: { type: 'array', items: { type: 'string' }, description: 'List of blockchain names (optional, defaults to all EVM chains)', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['address'], }, },

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/buildwithgrove/mcp-pocket'

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