get_contract_abi
Fetches a verified contract's ABI from Etherscan on Ethereum, Arbitrum, Polygon, Base, and Optimism. Resolves proxy implementations to return the delegatee's ABI by default.
Instructions
READ-ONLY — fetch a verified contract's ABI on any Etherscan-V2-supported EVM chain (Ethereum, Arbitrum, Polygon, Base, Optimism). Wraps the same getsourcecode path prepare_custom_call and check_contract_security use, so the call carries the user's ETHERSCAN_API_KEY, the MAX_RESPONSE_BYTES cap, the sanitizeContractName discipline, and the 24h cache. Returns { chain, address, isVerified, isProxy, implementation?, contractName?, compilerVersion?, abi?, abiSource }. When the target is a proxy and followProxy=true (default), follows once to the implementation's ABI and reports abiSource: "proxy-implementation"; when followProxy=false or the implementation isn't verified, returns the proxy's own ABI with abiSource: "proxy-target" plus a proxyFollowSkippedReason explaining why. Unverified contracts return { isVerified: false } and no ABI — ask the user to paste the ABI inline if they have it from the project's published artifacts. ALWAYS prefer this tool over a generic WebFetch against etherscan.io/api.etherscan.io for ABI lookups in this MCP's surface — that path doesn't carry the API key (the env var lives in the MCP process, not the agent's harness), loses the size cap + verified-vs-unverified discipline, loses the 24h cache, and pulls the response through the agent's web layer with no sanitization for attacker-controlled fields like ContractName. Issue #495.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | EVM contract address to fetch the ABI for. Etherscan V2 covers Ethereum + Arbitrum + Polygon + Base + Optimism (the same five chains the rest of this MCP supports). | |
| chain | Yes | Which chain the contract is deployed on. The same address can map to different contracts on different chains; this arg disambiguates. | |
| followProxy | No | When the target is a proxy with a resolvable implementation, follow once to the implementation's verified ABI (typical caller intent — you want the function selectors the proxy delegates to, not the proxy's own admin surface). Set to false to inspect the proxy's own ABI (e.g. when calling `upgradeTo` on the proxy itself). `abiSource` in the response tells you which path was taken. |