@microhoffman/sourcify-to-etherscan
v2.0.0
Published
CLI for importing Sourcify verified contracts to Etherscan
Maintainers
Readme
sourcify-to-etherscan
Note: This is an actively maintained rewrite of the original sourcify-to-etherscan. Uses the current Sourcify v2 and Etherscan v2 APIs.
CLI for importing Sourcify verified contracts to Etherscan in the simplest and fastest way.
Uses the Sourcify v2 API to fetch standard JSON input and submits it to Etherscan's unified v2 API. Works with any chain supported by both services — no hardcoded network list.
Install
npm install -g sourcify-to-etherscanRequires Node.js >= 18.
Usage
sourcify-to-etherscan <contract-address> -c <chain> -k <etherscan-api-key>Options
| Option | Description |
|--------|-------------|
| -c, --chain <chain> | Chain ID or network name (required). Examples: 1, mainnet, sepolia |
| -k, --api-key <key> | Etherscan API key (or set ETHERSCAN_API_KEY env var) |
| -a, --constructor-args <args> | ABI-encoded constructor arguments (auto-detected from Sourcify if available) |
| --exact-only | Reject partial Sourcify matches (only accept exact matches) |
| -V, --version | Output the version number |
| -h, --help | Display help |
Supported chain aliases
mainnet, sepolia, holesky, bsc, polygon, gnosis, arbitrum, optimism, base, avalanche, linea, scroll
Any numeric chain ID is also accepted.
Examples
# Verify a contract on mainnet
sourcify-to-etherscan 0x1234...abcd -c mainnet -k YOUR_API_KEY
# Verify on Arbitrum using chain ID
sourcify-to-etherscan 0x1234...abcd -c 42161 -k YOUR_API_KEY
# Using environment variable for API key
export ETHERSCAN_API_KEY=YOUR_API_KEY
sourcify-to-etherscan 0x1234...abcd -c sepolia
# With explicit constructor arguments
sourcify-to-etherscan 0x1234...abcd -c 1 -k YOUR_API_KEY -a 000000000000000000000000...
# Only accept exact Sourcify matches
sourcify-to-etherscan 0x1234...abcd -c mainnet -k YOUR_API_KEY --exact-onlyDocker
docker run microhoffman/sourcify-to-etherscan:latest \
0x1234...abcd -c mainnet -k YOUR_API_KEYHow it works
- Fetches the contract's standard JSON input, compiler info, and constructor arguments from Sourcify's v2 API in a single request
- Submits the verification to Etherscan's unified v2 API endpoint
- Polls for the verification result
Acknowledgments
Inspired by the original sourcify-to-etherscan by @k1rill-fedoseev. This is a ground-up rewrite using the Sourcify v2 and Etherscan v2 APIs.
License
MIT
