abi-retrieval

Fetch contract ABIs from Sourcify, Etherscan, and 4Byte Directory using .NET.

2.3k|744|Updated Nov 23, 2015
One-click install
npx skills add https://github.com/Nethereum/Nethereum --skill abi-retrieval
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: abi-retrieval
Source: https://github.com/Nethereum/Nethereum/tree/main/plugins/nethereum-skills/skills/abi-retrieval
Command: npx skills add https://github.com/Nethereum/Nethereum --skill abi-retrieval

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires Nethereum.DataServices, Nethereum.Sourcify.Database.

What problem does it solve?

Retrieving smart contract ABIs and decoding function signatures requires querying multiple external services with inconsistent availability, forcing developers to write their own fallback and caching logic.

Core Features & Use Cases

  • Composite ABI Lookup: Chain Sourcify, Etherscan, and 4Byte Directory sources with automatic fallback and in-memory caching via ABIInfoStorageFactory.
  • Signature Resolution: Find function, event, and error ABIs by 4-byte selector or topic hash, including batch lookups and proxy contract resolution.
  • Contract Verification: Verify contracts on Sourcify from Etherscan data or source files, and decode EVM trace calldata.
  • Use Case: Given an unknown contract address on Ethereum mainnet, retrieve its full ABI with contract name and function list, automatically falling back from Sourcify to Etherscan when the contract is not verified on the first source.

Quick Start

Ask the AI to fetch the ABI for a given contract address on a specific chain using Nethereum.DataServices with the composite Sourcify and Etherscan fallback chain.

Frequently Asked Questions about abi-retrieval

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I get a contract ABI from Etherscan or Sourcify in C#?

Use ABIInfoStorageFactory.CreateDefault with your Etherscan API key to build a fallback chain covering Sourcify, Etherscan, and 4Byte Directory. Call GetABIInfoAsync with the chain ID and contract address to retrieve the full ABI.

How to decode a 4-byte function selector to its signature?

Use FourByteDirectoryService.GetFunctionSignatureByHexSignatureAsync or Sourcify4ByteSignatureService.LookupAsync with the hex selector. Both return text signatures like transfer(address,uint256), and batch lookups are supported.

Does Nethereum ABI retrieval handle proxy contracts?

Yes, SourcifyABIInfoStorage resolves proxy contracts automatically when constructed with resolveProxies enabled. Calling GetABIInfoAsync on a proxy address returns the implementation contract's ABI.

Can I look up event and error ABIs by topic hash?

Yes, the composite storage provides FindEventABIAsync by topic hash and FindErrorABIAsync by error selector. Batch variants FindEventABIsBatchAsync and FindABIsBatchAsync handle multiple signatures in one call.

What happens when a contract is not verified on Sourcify?

The composite chain falls back to the next configured source, such as Etherscan, then Sourcify4Byte and 4Byte Directory for signature-level resolution. You can also build custom chains with CreateCustom to control the order.