npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

savecontract

v1.0.3

Published

A CLI tool to download verified smart contract source code from Etherscan and other block explorers using the Etherscan V2 API.

Readme

SaveContract

A CLI tool to download verified smart contract source code from Etherscan and other Etherscan-powered block explorers using the official V2 API.

Features

  • Multi-Chain Support: Download contracts from Ethereum, Base, Arbitrum, Polygon, and any other chain supported by the Etherscan V2 API.
  • Correct File Structure: Automatically parses the Standard JSON Input format to recreate the correct directory structure and file paths.
  • Easy to Use: Simple and intuitive command-line interface.
  • Environment Variable Support: Configure your API key once in a .env file.

Installation

You can run savecontract directly using npx without installation.

npx savecontract --address <contract_address> [options]

Or, you can install it globally for easier access:

npm install -g savecontract

Usage

Basic Command

savecontract --address <contract_address> --chainid <chain> --apikey <your_api_key> --output <directory>

Arguments and Options

| Long Flag | Short Flag | Description | Default | | ----------- | ------------ | ----------------------------------------------------------- | ------------------ | | --address | -a | (Required) The contract address to download. | - | | --chainid | -c, -cid | Chain ID or name (e.g., "1", "ethereum", "8453", "base"). | "1" (Ethereum) | | --output | -o | The output directory for the contract files. | ./smartcontracts | | --apikey | -k | Your Etherscan API key. Overrides the environment variable. | - | | --module | -m | API module to use. | "contract" | | --action | | API action to use. | "getsourcecode" | | --help | -h | Show help. | - | | --version | -v | Show version number. | - |

API Key Setup

An Etherscan API key (from the free tier) is required. You can provide it in two ways:

  1. Via Command Line (highest priority):

    savecontract -a 0x... -k YOUR_API_KEY
  2. Via .env file (recommended): Create a .env file in the directory where you are running the command and add your key:

    ETHERSCAN_API_KEY=YOUR_API_KEY

Examples

1. Download a contract from Base mainnet:

npx savecontract -a 0x03059433BCdB6144624cC2443159D9445C32b7a8 -c base -o ./base_contracts

(This assumes your API key is in a .env file)

2. Download a contract from Ethereum mainnet (default chain):

npx savecontract -a 0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413

3. Specify API key directly for a contract on Polygon:

npx savecontract --address 0x... --chainid polygon --apikey YOUR_API_KEY

Supported Chains

This tool supports any chain available on the Etherscan V2 API. Use either the chain ID or one of the convenient names below:

| Chain Name | Chain ID | | ------------------------- | ----------- | | Ethereum Mainnet | 1 | | Sepolia Testnet | 11155111 | | Holesky Testnet | 17000 | | Hoodi Testnet | 560048 | | Abstract Mainnet | 2741 | | Abstract Sepolia Testnet | 11124 | | ApeChain Curtis Testnet | 33111 | | ApeChain Mainnet | 33139 | | Arbitrum Nova Mainnet | 42170 | | Arbitrum One Mainnet | 42161 | | Arbitrum Sepolia Testnet | 421614 | | Avalanche C-Chain | 43114 | | Avalanche Fuji Testnet | 43113 | | Base Mainnet | 8453 | | Base Sepolia Testnet | 84532 | | Berachain Mainnet | 80094 | | Berachain Bepolia Testnet | 80069 | | BitTorrent Chain Mainnet | 199 | | BitTorrent Chain Testnet | 1028 | | Blast Mainnet | 81457 | | Blast Sepolia Testnet | 168587773 | | BNB Smart Chain Mainnet | 56 | | BNB Smart Chain Testnet | 97 | | Celo Alfajores Testnet | 44787 | | Celo Mainnet | 42220 | | Cronos Mainnet | 25 | | Fraxtal Mainnet | 252 | | Fraxtal Testnet | 2522 | | Gnosis | 100 | | HyperEVM | 999 | | Linea Mainnet | 59144 | | Linea Sepolia Testnet | 59141 | | Mantle Mainnet | 5000 | | Mantle Sepolia Testnet | 5003 | | Memecore Mainnet | 4352 | | Memecore Testnet | 43521 | | Moonbase Alpha Testnet | 1287 | | Monad Testnet | 10143 | | Moonbeam Mainnet | 1284 | | Moonriver Mainnet | 1285 | | OP Mainnet | 10 | | OP Sepolia Testnet | 11155420 | | Polygon Amoy Testnet | 80002 | | Polygon Mainnet | 137 | | Katana Mainnet | 747474 | | Scroll Mainnet | 534352 | | Scroll Sepolia Testnet | 534351 | | Sonic Blaze Testnet | 57054 | | Sonic Mainnet | 146 | | Sophon Mainnet | 50104 | | Sophon Sepolia Testnet | 531050104 | | Swellchain Mainnet | 1923 | | Swellchain Testnet | 1924 | | Taiko Hekla L2 Testnet | 167009 | | Taiko Mainnet | 167000 | | Unichain Mainnet | 130 | | Unichain Sepolia Testnet | 1301 | | WEMIX3.0 Mainnet | 1111 | | WEMIX3.0 Testnet | 1112 | | World Mainnet | 480 | | World Sepolia Testnet | 4801 | | Xai Mainnet | 660279 | | Xai Sepolia Testnet | 37714555429 | | XDC Apothem Testnet | 51 | | XDC Mainnet | 50 | | zkSync Mainnet | 324 | | zkSync Sepolia Testnet | 300 | | opBNB Mainnet | 204 | | opBNB Testnet | 5611 |

License

MIT