Skip to main content
Glama

get-token-balance

Retrieve ERC-20 token balances for any Ethereum address to monitor holdings or verify transactions.

Instructions

Get token balance of an address.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesAddress to get balance for.
tokenYesERC-20 token address to get balance for.

Implementation Reference

  • The handler function that executes the get-token-balance tool logic by calling wagmi's getBalance with the provided address and token.
    execute: async (args) => {
      const result = await getBalance(wagmiConfig, args);
      return {
        content: [
          {
            type: "text",
            text: JSONStringify(result),
          },
        ],
      };
    },
  • Input schema definition using Zod for the get-token-balance tool parameters: address and token addresses.
    parameters: z.object({
      address: Address.describe("Address to get balance for."),
      token: Address.describe("ERC-20 token address to get balance for."),
    }),
  • Direct registration of the get-token-balance tool on the FastMCP server instance, including name, description, schema, and handler.
    server.addTool({
      name: "get-token-balance",
      description: "Get token balance of an address.",
      parameters: z.object({
        address: Address.describe("Address to get balance for."),
        token: Address.describe("ERC-20 token address to get balance for."),
      }),
      execute: async (args) => {
        const result = await getBalance(wagmiConfig, args);
        return {
          content: [
            {
              type: "text",
              text: JSONStringify(result),
            },
          ],
        };
      },
    });
  • Intermediate registration call that invokes the registration of get-token-balance (among get-balance tools).
    registerGetBalanceTools(server, wagmiConfig);
  • src/index.ts:15-15 (registration)
    Top-level registration of all tools, which chains to including the get-token-balance tool.
    registerTools(server, wagmiConfig);

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/Xiawpohr/metamask-mcp'

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