get_token_metadata
Retrieve token metadata including name, symbol, decimals, and total supply from Grove's MCP Server for Pocket Network across 70+ blockchain networks.
Instructions
Get token metadata (name, symbol, decimals, total supply)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blockchain | Yes | Blockchain name | |
| tokenAddress | Yes | Token contract address | |
| network | No | Network type (defaults to mainnet) |
Implementation Reference
- Core handler function that implements getTokenMetadata by making parallel eth_call RPC requests to the token contract for name, symbol, decimals, and total supply.async getTokenMetadata( blockchain: string, tokenAddress: string, network: 'mainnet' | 'testnet' = 'mainnet' ): Promise<EndpointResponse> { const service = this.blockchainService.getServiceByBlockchain(blockchain, network); if (!service) { return { success: false, error: `Blockchain service not found: ${blockchain} (${network})`, }; } try { // Call all methods in parallel const [decimalsResult, symbolResult, nameResult, totalSupplyResult] = await Promise.all([ this.blockchainService.callRPCMethod( service.id, 'eth_call', [{ to: tokenAddress, data: AdvancedBlockchainService.ERC20_DECIMALS }, 'latest'] ), this.blockchainService.callRPCMethod( service.id, 'eth_call', [{ to: tokenAddress, data: AdvancedBlockchainService.ERC20_SYMBOL }, 'latest'] ), this.blockchainService.callRPCMethod( service.id, 'eth_call', [{ to: tokenAddress, data: AdvancedBlockchainService.ERC20_NAME }, 'latest'] ), this.blockchainService.callRPCMethod( service.id, 'eth_call', [{ to: tokenAddress, data: AdvancedBlockchainService.ERC20_TOTAL_SUPPLY }, 'latest'] ), ]); return { success: true, data: { address: tokenAddress, decimals: decimalsResult.success ? parseInt(decimalsResult.data, 16) : null, symbol: symbolResult.success ? this.decodeString(symbolResult.data) : null, name: nameResult.success ? this.decodeString(nameResult.data) : null, totalSupply: totalSupplyResult.success ? BigInt(totalSupplyResult.data).toString() : null, }, metadata: { timestamp: new Date().toISOString(), endpoint: service.rpcUrl, }, }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : 'Failed to fetch token metadata', }; } }
- src/handlers/token-handlers.ts:106-122 (handler)MCP dispatch handler case for 'get_token_metadata' tool that extracts parameters and calls the advanced blockchain service.case 'get_token_metadata': { const blockchain = args?.blockchain as string; const tokenAddress = args?.tokenAddress as string; const network = (args?.network as 'mainnet' | 'testnet') || 'mainnet'; const result = await advancedBlockchain.getTokenMetadata(blockchain, tokenAddress, network); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], isError: !result.success, }; }
- src/index.ts:92-92 (registration)Registration of token tools including get_token_metadata via registerTokenHandlers call during server initialization....registerTokenHandlers(server, advancedBlockchain),
- src/handlers/token-handlers.ts:42-64 (schema)Tool schema definition including input schema for blockchain, tokenAddress, and optional network.{ name: 'get_token_metadata', description: 'Get token metadata (name, symbol, decimals, total supply)', inputSchema: { type: 'object', properties: { blockchain: { type: 'string', description: 'Blockchain name', }, tokenAddress: { type: 'string', description: 'Token contract address', }, network: { type: 'string', enum: ['mainnet', 'testnet'], description: 'Network type (defaults to mainnet)', }, }, required: ['blockchain', 'tokenAddress'], }, },