get_token_info
Retrieve detailed ERC20 token metadata, including name, symbol, decimals, and total supply, for analysis on EVM-compatible chains such as Ethereum, Polygon, and Arbitrum.
Instructions
Get comprehensive information about an ERC20 token including name, symbol, decimals, total supply, and other metadata. Use this to analyze any token on EVM chains.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | No | Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Defaults to Ethereum mainnet. | |
| tokenAddress | Yes | The contract address of the ERC20 token (e.g., '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' for USDC on Ethereum) |
Implementation Reference
- src/core/tools.ts:1291-1342 (handler)MCP tool registration and handler for get_token_info. Defines input schema, executes by calling services.getERC20TokenInfo, and formats response as JSON.server.tool( 'get_token_info', 'Get comprehensive information about an ERC20 token including name, symbol, decimals, total supply, and other metadata. Use this to analyze any token on EVM chains.', { tokenAddress: z .string() .describe( "The contract address of the ERC20 token (e.g., '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' for USDC on Ethereum)" ), network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Defaults to Ethereum mainnet." ) }, async ({ tokenAddress, network = 'ethereum' }) => { try { const tokenInfo = await services.getERC20TokenInfo( tokenAddress as Address, network ); return { content: [ { type: 'text', text: JSON.stringify( { address: tokenAddress, network, ...tokenInfo }, null, 2 ) } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error fetching token info: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
- src/core/services/tokens.ts:81-113 (helper)Core helper function that reads ERC20 contract for name, symbol, decimals, totalSupply using viem getContract and read methods.export async function getERC20TokenInfo( tokenAddress: Address, network: string = 'ethereum' ): Promise<{ name: string; symbol: string; decimals: number; totalSupply: bigint; formattedTotalSupply: string; }> { const publicClient = getPublicClient(network); const contract = getContract({ address: tokenAddress, abi: erc20Abi, client: publicClient, }); const [name, symbol, decimals, totalSupply] = await Promise.all([ contract.read.name(), contract.read.symbol(), contract.read.decimals(), contract.read.totalSupply() ]); return { name, symbol, decimals, totalSupply, formattedTotalSupply: formatUnits(totalSupply, decimals) }; }
- src/core/tools.ts:1295-1306 (schema)Zod input schema for get_token_info tool defining tokenAddress and optional network parameters.tokenAddress: z .string() .describe( "The contract address of the ERC20 token (e.g., '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' for USDC on Ethereum)" ), network: z .string() .optional() .describe( "Network name (e.g., 'ethereum', 'optimism', 'arbitrum', 'base', 'polygon') or chain ID. Defaults to Ethereum mainnet." ) },
- src/core/services/tokens.ts:11-40 (helper)ERC20 ABI constants used by getERC20TokenInfo to read standard ERC20 functions.const erc20Abi = [ { inputs: [], name: 'name', outputs: [{ type: 'string' }], stateMutability: 'view', type: 'function' }, { inputs: [], name: 'symbol', outputs: [{ type: 'string' }], stateMutability: 'view', type: 'function' }, { inputs: [], name: 'decimals', outputs: [{ type: 'uint8' }], stateMutability: 'view', type: 'function' }, { inputs: [], name: 'totalSupply', outputs: [{ type: 'uint256' }], stateMutability: 'view', type: 'function' } ] as const;
- src/server/server.ts:18-18 (registration)Top-level registration call in server startup that includes get_token_info via registerEVMTools.registerEVMTools(server);