Etherscan API
Apps & Automationetherscan-apiEtherscan API is an Agent Skill for apps & automation published in the Nethereum/Nethereum repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Query Etherscan V2 API for gas prices, account transactions, balances, token transfers, contract source code, and compilation metadata via Nethereum.DataServices
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/Nethereum/Nethereum/blob/HEAD/plugins/nethereum-skills/skills/etherscan-api/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/etherscan-api, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Etherscan API
Query the Etherscan V2 unified API across all Etherscan-supported chains using Nethereum.DataServices.
NuGet Package: Nethereum.DataServices
Installation
dotnet add package Nethereum.DataServices
Quick Start
using Nethereum.DataServices.Etherscan;
var etherscan = new EtherscanApiService(chain: 1, apiKey: "YOUR_ETHERSCAN_API_KEY");
// Gas prices
var gas = await etherscan.GasTracker.GetGasOracleAsync();
Console.WriteLine($"Safe: {gas.Result.SafeGasPrice} Gwei");
Console.WriteLine($"Proposed: {gas.Result.ProposeGasPrice} Gwei");
Console.WriteLine($"Fast: {gas.Result.FastGasPrice} Gwei");
// Account balance
var balance = await etherscan.Accounts.GetBalanceAsync("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
Console.WriteLine($"Balance: {balance.Result} Wei");
// Contract ABI
var abi = await etherscan.Contracts.GetAbiAsync("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48");
Sub-Services
| Property | Class | Description |
|---|---|---|
Contracts | EtherscanApiContractsService | ABI, source code, contract creator |
Accounts | EtherscanApiAccountsService | Balances, transactions, token transfers |
GasTracker | EtherscanApiGasTrackerService | Gas oracle, confirmation estimates |
Gas Tracker
// Gas oracle with price tiers
var response = await etherscan.GasTracker.GetGasOracleAsync();
var gas = response.Result;
// gas.SafeGasPrice, gas.ProposeGasPrice, gas.FastGasPrice, gas.SuggestBaseFee, gas.GasUsedRatio
// Confirmation time estimate (gas price in Wei)
var estimate = await etherscan.GasTracker.GetEstimatedConfirmationTimeAsync(gasPriceInWei: 30_000_000_000);
Console.WriteLine($"Seconds to confirm: {estimate.Result}");
Account Queries
// Single balance
var balance = await etherscan.Accounts.GetBalanceAsync("0x...");
// Multiple balances
var balances = await etherscan.Accounts.GetBalancesAsync(new[] { "0x...", "0x..." });
// Transaction history (paginated)
var txns = await etherscan.Accounts.GetAccountTransactionsAsync("0x...", page: 1, offset: 10, sort: "desc");
// Internal transactions
var internal = await etherscan.Accounts.GetAccountInternalTransactionsAsync("0x...", page: 1, offset: 10, sort: "desc");
// ERC-20 token transfers
var transfers = await etherscan.Accounts.GetTokenTransfersAsync("0x...");
// ERC-721 (NFT) transfers
var nfts = await etherscan.Accounts.GetErc721TransfersAsync("0x...");
// ERC-1155 transfers
var multi = await etherscan.Accounts.GetErc1155TransfersAsync("0x...");
// Funded by
var funded = await etherscan.Accounts.GetFundedByAsync("0x...");
Contract Data
// ABI as JSON string
var abiResponse = await etherscan.Contracts.GetAbiAsync("0x...");
string abi = abiResponse.Result;
// Source code and compilation metadata
var source = await etherscan.Contracts.GetSourceCodeAsync("0x...");
var info = source.Result.First();
Console.WriteLine($"Name: {info.ContractName}, Compiler: {info.CompilerVersion}");
// Contract creator and deployment tx
var creator = await etherscan.Contracts.GetContractCreatorAndCreationTxHashAsync("0x...");
Multi-Chain Usage
Same API key works across all Etherscan V2 chains:
var polygonApi = new EtherscanApiService(chain: 137, apiKey: "YOUR_KEY");
var arbApi = new EtherscanApiService(chain: 42161, apiKey: "YOUR_KEY");
var baseApi = new EtherscanApiService(chain: 8453, apiKey: "YOUR_KEY");
Sourcify Parquet Exports
using Nethereum.DataServices.Sourcify;
var parquet = new SourcifyParquetExportService();
var files = await parquet.ListTableFilesAsync("verified_contracts");
using var stream = await parquet.DownloadFileAsync(files.First().Key);
Key Namespaces
Nethereum.DataServices.Etherscan— Etherscan API service and response modelsNethereum.DataServices.Sourcify— Sourcify Parquet export service