Skip to main content
Glama

wallet_get_balance

Retrieve the balance of an Ethereum or EVM-compatible wallet using a private key, mnemonic, or JSON. Optionally, specify a block tag to query the balance at a specific point in time.

Instructions

Get the balance of the wallet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockTagNoOptional block tag (latest, pending, etc.)
walletNoThe wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set.

Implementation Reference

  • The main handler function for wallet_get_balance tool. It gets the wallet instance, calls getBalance on it with optional blockTag, formats the result, and returns a success or error response.
    export const getBalanceHandler = async (input: any): Promise<ToolResultSchema> => { try { const wallet = await getWallet(input.wallet, input.password); const balance = await wallet.getBalance(input.blockTag ?? "latest"); return createSuccessResponse( `Wallet balance retrieved successfully Balance: ${balance.toString()} Balance in ETH: ${ethers.utils.formatEther(balance)} `); } catch (error) { return createErrorResponse(`Failed to get wallet balance: ${(error as Error).message}`); } };
  • The input schema definition for the wallet_get_balance tool, including name, description, and inputSchema properties.
    { name: "wallet_get_balance", description: "Get the balance of the wallet", inputSchema: { type: "object", properties: { wallet: { type: "string", description: "The wallet (private key, mnemonic, or JSON). If not provided, uses PRIVATE_KEY environment variable if set." }, blockTag: { type: "string", description: "Optional block tag (latest, pending, etc.)" } }, required: [] } },
  • src/tools.ts:572-572 (registration)
    The registration entry in the handlers dictionary that maps 'wallet_get_balance' to the getBalanceHandler function.
    "wallet_get_balance": getBalanceHandler,

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/dcSpark/mcp-cryptowallet-evm'

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