Skip to main content
Glama
5ajaki
by 5ajaki

ethereum_getContractInfo

Retrieve detailed information about Ethereum smart contracts, including code and metadata, by specifying the contract address or ENS name using the Veri5ight MCP Server.

Instructions

Get information about any contract

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesContract address or ENS name

Implementation Reference

  • Main handler function for ethereum_getContractInfo tool. Retrieves contract bytecode size and attempts to fetch ERC20 token metadata (name, symbol, decimals, total supply).
    private async handleGetContractInfo(request: any) { try { const address = request.params.arguments?.address; if (!address) { throw new Error("Address is required"); } // Get basic contract info const code = await this.provider.getCode(address); if (code === "0x") { throw new Error("No contract found at this address"); } // Try to get ERC20 info if available let tokenInfo = ""; try { const contract = new ethers.Contract(address, ERC20_ABI, this.provider); const [name, symbol, decimals, totalSupply] = await Promise.all([ contract.name().catch(() => null), contract.symbol().catch(() => null), contract.decimals().catch(() => null), contract.totalSupply().catch(() => null), ]); if (name || symbol || decimals || totalSupply) { tokenInfo = `\n\nERC20 Token Information: • Name: ${name || "N/A"} • Symbol: ${symbol || "N/A"} • Decimals: ${decimals || "N/A"} • Total Supply: ${ totalSupply ? ethers.formatUnits(totalSupply, decimals || 18) : "N/A" } ${symbol || ""}`; } } catch (error) { console.error("Not an ERC20 token or error getting token info:", error); } return { content: [ { type: "text", text: `Contract Information for ${address}: • Bytecode Size: ${(code.length - 2) / 2} bytes • Contract Address: ${address}${tokenInfo}`, }, ], }; } catch (error: unknown) { console.error("Error getting contract info:", error); const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; return { content: [ { type: "text", text: `Error getting contract info: ${errorMessage}`, }, ], }; } }
  • Tool schema definition including name, description, and input schema requiring 'address' parameter.
    { name: "ethereum_getContractInfo", description: "Get information about any contract", inputSchema: { type: "object", properties: { address: { type: "string", description: "Contract address or ENS name", }, }, required: ["address"], },
  • src/index.ts:151-165 (registration)
    Switch statement in CallToolRequestSchema handler that registers and dispatches to the ethereum_getContractInfo handler.
    switch (request.params.name) { case "ethereum_getRecentTransactions": return await this.handleGetRecentTransactions(request); case "ethereum_getTokenBalance": return await this.handleGetTokenBalance(request); case "ethereum_getTokenDelegation": return await this.handleGetTokenDelegation(request); case "ethereum_getContractInfo": return await this.handleGetContractInfo(request); case "ethereum_getTransactionInfo": return await this.handleGetTransactionInfo(request); default: throw new Error(`Unknown tool: ${request.params.name}`); } });
  • src/index.ts:57-145 (registration)
    Registration of tool list including ethereum_getContractInfo schema in ListToolsRequestSchema handler.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => { console.error("tools/list called"); return { tools: [ { name: "ethereum_getRecentTransactions", description: "Get recent transactions for an Ethereum address", inputSchema: { type: "object", properties: { address: { type: "string", description: "Ethereum address or ENS name", }, limit: { type: "number", description: "Number of transactions to return (default: 3)", }, }, required: ["address"], }, }, { name: "ethereum_getTokenBalance", description: "Get ERC20 token balance for an address", inputSchema: { type: "object", properties: { address: { type: "string", description: "Ethereum address or ENS name", }, token: { type: "string", description: "Token contract address or ENS name", }, }, required: ["address", "token"], }, }, { name: "ethereum_getTokenDelegation", description: "Get delegation info for an ERC20 governance token", inputSchema: { type: "object", properties: { address: { type: "string", description: "Ethereum address or ENS name", }, token: { type: "string", description: "Token contract address or ENS name", }, }, required: ["address", "token"], }, }, { name: "ethereum_getContractInfo", description: "Get information about any contract", inputSchema: { type: "object", properties: { address: { type: "string", description: "Contract address or ENS name", }, }, required: ["address"], }, }, { name: "ethereum_getTransactionInfo", description: "Get detailed information about an Ethereum transaction", inputSchema: { type: "object", properties: { hash: { type: "string", description: "Transaction hash", }, }, required: ["hash"], }, }, ], };
  • ERC20 ABI constants used by the handler to query token metadata.
    const ERC20_ABI = [ "function name() view returns (string)", "function symbol() view returns (string)", "function decimals() view returns (uint8)", "function totalSupply() view returns (uint256)", "function balanceOf(address) view returns (uint256)", ];

Other Tools

Related Tools

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/5ajaki/veri5ight'

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