Skip to main content
Glama

evm_get_contract_abi

Fetches a verified smart contract's ABI from a chain's block explorer to enable function calls and transaction decoding, or returns manual retrieval steps when API access is unavailable.

Instructions

Get contract ABI from block explorer API or provide guidance on manual retrieval (placeholder implementation).

Attempts to fetch contract ABI automatically from block explorer. For verified contracts, returns full ABI including all functions, events, and data structures. Currently provides guidance for manual retrieval.

CRITICAL RULES:

  • Only works for verified contracts on block explorer

  • Unverified contracts don't expose ABI publicly

  • Some explorers require API keys for programmatic access

  • Manual retrieval often more reliable than API

  • ABI is critical for all contract interactions

  • This is PLACEHOLDER - may return retrieval guidance instead of ABI

PARAMETERS:

  • chain: EVM chain where contract is deployed (required)

    • Each chain has different block explorer

    • API access varies by explorer

  • contractAddress: Smart contract address (required)

    • Format: 0x followed by 40 hex characters

    • Contract must be verified on block explorer

    • Examples: DEX routers, token contracts, NFT collections

EXAMPLES: ✅ Get ABI for verified USDC on Polygon: {chain: "polygon", contractAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}

✅ Get ABI for Uniswap Router on Ethereum: {chain: "ethereum", contractAddress: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"}

✅ Get ABI for verified custom contract (BSC): {chain: "bsc", contractAddress: "0xCustomContract..."}

❌ Invalid - unverified contract: {contractAddress: "0xUnverified..."} // ABI not available

❌ Invalid - wrong chain: {chain: "polygon", contractAddress: "0xEthereumOnly..."} // Contract not on Polygon

SUPPORTED EVM CHAINS (7 networks): • ethereum (Sepolia) - EIP-1559 enabled, ~12s blocks, moderate gas costs • polygon (Amoy) - Low fees, fast finality (~2s), layer 2 • avalanche (Fuji C-Chain) - Sub-second finality, dynamic fees • bsc (BNB Testnet) - 3s blocks, low gas costs, Binance ecosystem • arbitrum (Sepolia) - Optimistic rollup, low fees, Ethereum security • base (Sepolia) - Coinbase layer 2, EIP-1559, low fees • worldchain (World Sepolia) - World Network testnet, EIP-1559

CRITICAL GAS CONSIDERATIONS:

  • Ethereum: High gas costs, use gas oracle for timing

  • Polygon/BSC: Very low gas, safe for frequent transactions

  • Arbitrum/Base: L2 optimizations, ~10-50x cheaper than Ethereum

  • Avalanche: Dynamic fees, can spike during congestion

  • Always check gas price before executing transactions

TESTNET TOKENS: All chains use testnet tokens with NO REAL VALUE. Faucets available for all supported networks.

OUTPUT STRUCTURE: • success: Boolean indicating retrieval success • chain: Chain queried • contractAddress: Contract address • abi: Contract ABI (JSON array) if available • verified: Boolean indicating if contract is verified • retrievalMethod: How ABI was obtained (api/manual) • blockExplorerUrl: URL to view contract on explorer • manualInstructions: Steps for manual ABI retrieval • executionTime: Time taken in milliseconds

COMMON MISTAKES:

  • Trying to get ABI for unverified contracts

  • Using wrong block explorer for chain

  • Not having API key for explorer (if required)

  • Confusing contract address with implementation address (proxies)

USE CASES:

  • Get ABI before calling contract functions

  • Explore contract interface and capabilities

  • Verify contract functionality matches documentation

  • Decode transaction data

  • Build UI for contract interaction

BLOCK EXPLORERS BY CHAIN:

  • Ethereum Sepolia: sepolia.etherscan.io

  • Polygon Amoy: amoy.polygonscan.com

  • Avalanche Fuji: testnet.snowtrace.io

  • BSC Testnet: testnet.bscscan.com

  • Arbitrum Sepolia: sepolia.arbiscan.io

  • Base Sepolia: sepolia.basescan.org

  • World Chain: worldchain.explorer.io

MANUAL ABI RETRIEVAL STEPS:

  1. Go to block explorer for your chain

  2. Enter contract address in search bar

  3. Navigate to "Contract" tab

  4. Look for "Contract ABI" section (verified contracts only)

  5. Copy ABI JSON array

  6. Use in evm_call_contract or evm_send_contract_transaction

VERIFICATION STATUS: Verified contracts show:

  • ✅ Green checkmark on explorer

  • Source code tab available

  • Contract ABI visible

  • Compiler settings shown

  • Contract name displayed

Unverified contracts show:

  • ❌ No verification badge

  • Only bytecode visible

  • No ABI available

  • Must get ABI from project docs

PROXY CONTRACTS: For proxy patterns (common in upgradeable contracts):

  1. Get ABI from implementation contract, not proxy

  2. Proxy address for transactions

  3. Implementation ABI for function calls

  4. Explorer often detects and shows both

ALTERNATIVE ABI SOURCES:

  1. Project GitHub repository

  2. Project documentation

  3. npm packages (@uniswap/v2-core)

  4. Etherscan "Read/Write Contract" tab

  5. Contract deployment transaction logs

COMMON CONTRACT ABIS: Standard interfaces often available in libraries:

  • ERC20: @openzeppelin/contracts

  • ERC721: @openzeppelin/contracts

  • ERC1155: @openzeppelin/contracts

  • Uniswap V2: @uniswap/v2-core

  • Uniswap V3: @uniswap/v3-core

API KEY REQUIREMENTS: Some explorers require API keys:

  • Etherscan: Free tier available

  • PolygonScan: Free tier available

  • BSCScan: Free tier available

  • Others: Check explorer docs

PLACEHOLDER NOTE: This tool currently provides guidance for manual retrieval. Full API integration coming in future updates. For now, use manual retrieval from block explorer.

Running on Linux.

LINUX-SPECIFIC NOTES:

  • Package manager: apt (Ubuntu/Debian), yum (RHEL/CentOS), or pacman (Arch)

  • Python 3 is typically 'python3' command

  • GNU tools are standard

  • Use 'xdg-open' command to open files/applications

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "chain": "<chain>",
      "contractAddress": "<contractAddress>"
    },
    "name": "evm_get_contract_abi"
  }
}

Input Schema

NameRequiredDescriptionDefault
chainYesEVM chain to query
contractAddressYesSmart contract address (0x...)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and mostly meets it: it discloses the placeholder status, that unverified contracts expose no ABI, that some explorers need API keys, and it enumerates the return fields (success, abi, verified, retrievalMethod, manualInstructions). The caveat is self-contradiction in tone — 'attempts to fetch automatically' versus 'currently provides guidance for manual retrieval' — which a reader must reconcile from the PLACEHOLDER NOTE.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A short definition is buried in a wall of largely irrelevant material: gas cost commentary, testnet faucets, a list of common OpenZeppelin interfaces, verification badge descriptions, and a closing 'LINUX-SPECIFIC NOTES' section about apt/yum/pacman that has nothing to do with retrieving an ABI. The core facts (placeholder status, verified-only constraint, return shape) are present but not front-loaded relative to their importance, and the duplication of the placeholder warning wastes space.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, and the description does document the return structure field by field, so the agent knows what to expect. However, the signal-to-noise ratio is poor: the injected Linux notes and gas guidance are unrelated to this tool and could mislead an agent into thinking the tool handles transactions or system tasks. Completeness is achieved by volume rather than by disciplined coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is already 100%, so the baseline is 3, but the description adds real meaning beyond it: the chain parameter is tied to a specific block explorer per network, and contractAddress is given a format rule (0x + 40 hex) and worked examples with real addresses. The invalid-example pairs also communicate the chain/address coupling that the enum alone does not.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening lines state a specific verb and resource: fetch a contract ABI from a block explorer, with the scope constraint that it only works for verified contracts. It also flags that this is a placeholder returning guidance rather than an ABI. The purpose is unmistakable, though the sibling differentiation is incidental (a passing mention of evm_call_contract / evm_send_contract_transaction) rather than deliberate routing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The definition supplies concrete USE CASES (decode transaction data, explore interface, build UI) and an explicit failure taxonomy (unverified contract, wrong chain, missing API key, proxy vs implementation address). It also lists alternative ABI sources (GitHub, npm, docs) for the case where this tool cannot deliver. It stops short of naming a sibling tool as the alternative for the retrieval-failure path.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools