get_token_info
Retrieve ERC-20 token details including name, symbol, decimals, total supply, and owner balance from a Base contract address.
Instructions
Get info about a deployed ERC-20 token: name, symbol, decimals, total supply, and owner balance.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_address | Yes | Token contract address on Base |
Implementation Reference
- src/index.ts:222-256 (handler)Handler for the get_token_info tool, which queries an ERC-20 token's metadata and supply using ethers.js.
async ({ token_address }) => { try { const provider = getProvider(); const token = new ethers.Contract(token_address, TOKEN_ABI, provider); const [name, symbol, decimals, totalSupply] = await Promise.all([ token.name(), token.symbol(), token.decimals(), token.totalSupply(), ]); // Check if we have deploy record const record = deployments.find( (d) => d.tokenAddress.toLowerCase() === token_address.toLowerCase() ); const result: Record<string, unknown> = { token_address, name, symbol, decimals: Number(decimals), total_supply: ethers.formatUnits(totalSupply, decimals), explorer: `https://basescan.org/token/${token_address}`, }; if (record) { result.owner = record.owner; result.deployer = record.deployer; result.deployed_at = new Date(record.timestamp * 1000).toISOString(); result.was_gasless = record.usedPaymaster; // Get owner balance const ownerBalance = await token.balanceOf(record.owner); result.owner_balance = ethers.formatUnits(ownerBalance, decimals); - src/index.ts:216-221 (registration)Registration of the get_token_info tool with its schema definition using zod.
server.tool( "get_token_info", "Get info about a deployed ERC-20 token: name, symbol, decimals, total supply, and owner balance.", { token_address: z.string().describe("Token contract address on Base"), },