xplorer
Etherscan API CLI wrapper. Query blockchain data from the terminal using the Etherscan V2 API, with multichain support via a single API key.
The goal is to cover all modules and routes exposed by the Etherscan API. This is a work in progress. Currently supported:
- contract module
getabi- Get the ABI of a verified contractgetsourcecode- Get the source code of a verified contractgetcontractcreation- Get contract creation info (creator address + deployment tx hash)
Installation
Configuration
Set your Etherscan API key:
# Interactive mode (recommended - input is hidden)
# Or pass directly (visible in shell history)
Config is stored at ~/.xplorer/config.toml.
Usage
Chain ID
Every query requires a chain ID, provided via the --chain-id flag:
xplorer is also compatible with Stargate, a blockchain network switcher CLI for Foundry. When you switch networks with Stargate, it exports a STARGATE_CHAIN_ID environment variable that xplorer picks up automatically, so you don't need to pass --chain-id on every call:
If both are provided, the --chain-id flag takes precedence.
Contract Module
# Get the ABI of a verified contract (pretty-printed JSON)
# Get full source code with metadata (compiler, optimization, license, proxy info)
# Get contract creation info (creator address + deployment tx hash)
# Query multiple contracts at once (up to 5)
Supported Chains
xplorer uses the Etherscan V2 API, which supports 60+ chains through a single endpoint. Pass any valid chain ID:
| Chain | Chain ID |
|---|---|
| Ethereum | 1 |
| Arbitrum | 42161 |
| Base | 8453 |
| Optimism | 10 |
| Polygon | 137 |
| BSC | 56 |
| Linea | 59144 |
| Scroll | 534352 |
| zkSync | 324 |
See the full list at docs.etherscan.io.
Developers
Building from Source
The binary will be at target/release/xplorer.
Local Installation
Option 1: Install globally (replaces any existing installation)
Option 2: Test without installing
Running Tests
Git Hooks
This project uses lefthook for git hooks.
# Install lefthook (macOS)
# Install hooks
Hooks run automatically on commit (fmt, clippy) and push (test, build).