Skip to main content
Glama

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
NameRequiredDescriptionDefault
networkNoNetwork name (e.g. 'bsc', 'opbnb', 'ethereum', 'base', etc.) or chain ID. Supports others main popular networks. Defaults to BSC mainnet.bsc
tokenAddressYesThe ERC20 token contract address

Implementation Reference

  • 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) } }
  • 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 },

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/bnb-chain/bnbchain-mcp'

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