get_erc20_token_info
Retrieve detailed ERC20 token information by providing the token contract address and network. Works across popular networks like BSC, Ethereum, and others for comprehensive token insights.
Instructions
Get ERC20 token information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | No | Network name (e.g. 'bsc', 'opbnb', 'ethereum', 'base', etc.) or chain ID. Supports others main popular networks. Defaults to BSC mainnet. | bsc |
| tokenAddress | Yes | The ERC20 token contract address |
Implementation Reference
- src/evm/services/tokens.ts:13-49 (handler)The core handler function `getERC20TokenInfo` that retrieves ERC20 token details (name, symbol, decimals, total supply) using viem contract interface.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 isContractAddr = await isContract(tokenAddress, network) if (!isContractAddr) { throw new Error("Token address is not a contract") } const contract = getContract({ address: tokenAddress, abi: ERC20_ABI, client: publicClient }) const [name, symbol, decimals, totalSupply] = await Promise.all([ contract.read.name() as Promise<string>, contract.read.symbol() as Promise<string>, contract.read.decimals() as Promise<number>, contract.read.totalSupply() as Promise<bigint> ]) return { name, symbol, decimals, totalSupply, formattedTotalSupply: formatUnits(totalSupply, decimals) } }
- src/evm/modules/tokens/tools.ts:12-31 (registration)MCP tool registration for 'get_erc20_token_info', including input schema and handler invocation.server.tool( "get_erc20_token_info", "Get ERC20 token information", { tokenAddress: z.string().describe("The ERC20 token contract address"), network: defaultNetworkParam }, async ({ network, tokenAddress }) => { try { const tokenInfo = await services.getERC20TokenInfo( tokenAddress as Address, network ) return mcpToolRes.success(tokenInfo) } catch (error) { return mcpToolRes.error(error, "fetching ERC20 token info") } } )
- Zod input schema defining parameters for the tool.{ tokenAddress: z.string().describe("The ERC20 token contract address"), network: defaultNetworkParam },