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
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | Address to get balance for. | |
| token | Yes | ERC-20 token address to get balance for. |
Implementation Reference
- src/tools/get-balance.ts:35-45 (handler)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), }, ], }; },
- src/tools/get-balance.ts:31-34 (schema)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."), }),
- src/tools/get-balance.ts:28-46 (registration)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), }, ], }; }, });
- src/tools/register-tools.ts:41-41 (registration)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);