Skip to main content
Glama
buildwithgrove

Grove Public Endpoints MCP Server

Official

compare_balances

Check native token balances for a single address across multiple EVM blockchain networks to compare holdings.

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 handler function that implements the balance comparison logic across multiple EVM-compatible blockchains by calling eth_getBalance RPC on each chain and aggregating results.
    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', }; } }
  • Tool registration object defining the name, description, and input schema for the compare_balances tool.
    { 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'], }, },
  • Tool dispatcher case that parses input arguments and delegates to the core service implementation.
    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, }; }
  • Helper method used by compareBalances to determine the list of EVM chains to check when none are specified.
    private getEVMChains(): string[] { const evmChains = this.blockchainService.getAllServices() .filter(s => (s.category === 'evm' || s.category === 'layer2') && s.network === 'mainnet') .map(s => s.blockchain); return [...new Set(evmChains)]; }

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'

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