A fast CLI for fetching verified smart contract source code — and querying blockchain data — across multiple chains.
# Fetch USDC source code and save all files locally
etherscan contract source 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 -c ethereum --save ./usdcThis is the primary use case. All three subcommands work on any supported chain.
# Show contract metadata (name, compiler, license, proxy status)
etherscan contract source <ADDRESS> -c <CHAIN>
# Print source to stdout
etherscan contract source <ADDRESS> -c <CHAIN> --print
# Save all source files to a directory
etherscan contract source <ADDRESS> -c <CHAIN> --save ./outputMulti-file contracts (Hardhat / standard JSON input format) are automatically unpacked — the original directory structure is preserved under ./output.
Proxy contracts show the implementation address:
Contract TransparentUpgradeableProxy
Compiler v0.8.4+commit.c7e474f2
Optimization Yes (200 runs)
License MIT
Proxy Yes (impl: 0x43506849D7C04F9138D1A2050bbF3A0c054402dd)
Chain ethereum
etherscan contract abi <ADDRESS> -c <CHAIN>etherscan contract bytecode <ADDRESS> -c <CHAIN>etherscan balance <ADDRESS> -c <CHAIN> ETH balance
etherscan txlist <ADDRESS> -c <CHAIN> Recent transactions
etherscan transfers <ADDRESS> -c <CHAIN> ERC-20 / NFT transfers
etherscan gas -c <CHAIN> Current gas prices
etherscan token <CONTRACT> -c <CHAIN> ERC-20 token info
etherscan tx <TX_HASH> -c <CHAIN> Transaction details
etherscan block <NUMBER> -c <CHAIN> Block details
etherscan chains List supported chains
Add --json to any command for machine-readable output.
Download from Releases and put it on your $PATH.
curl -fsSL https://raw.githubusercontent.com/lxhyl/etherscan-cli/main/install.sh | shRe-run anytime to update to the latest version.
cargo install etherscan-cliGet a free API key at etherscan.io/apis — the same key works for most EVM-compatible chains.
etherscan config set-key <YOUR_API_KEY>| Name | Aliases | Chain ID |
|---|---|---|
| ethereum | eth, mainnet | 1 |
| polygon | matic | 137 |
| bsc | bnb, binance | 56 |
| arbitrum | arb | 42161 |
| optimism | op | 10 |
| base | — | 8453 |
| avalanche | avax | 43114 |
| linea | — | 59144 |
| scroll | — | 534352 |
Run etherscan chains for the full list including testnets.
MIT