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 🙏

© 2024 – Pkg Stats / Ryan Hefner

hardhat-etherscan-contract-cloner

v1.0.6

Published

Hardhat plugin for cloning contracts from ethereum using etherscan

Downloads

10

Readme

hardhat-etherscan-contract-cloner

Hardhat plugin for cloning verified contracts from any supported network using Etherscan's API.

What

This plugin will help you clone any verified contract with its source code available in Etherscan to your local project.

The main contract will be copied in your contracts folder. Any imported contract will be copied to contracts/etherscan-imported folder.

Installation

npm install --save-dev hardhat-etherscan-contract-cloner

Import the plugin in your hardhat.config.js:

require("hardhat-etherscan-contract-cloner");

Or if you are using TypeScript, in your hardhat.config.ts:

import "hardhat-etherscan-contract-cloner";

Tasks

This plugin adds the clone task to Hardhat, which allows you to clone any contract from the supported networks.

Environment extensions

This plugin does not extend the environment.

Configuration

This plugin extends the Hardhat configuration object to add Etherscan config to it. In your hardhat.config.js file add:

module.exports = {
  networks: {
    mainnet: { ... }
  },
  etherscan: {
    // Your API key for Etherscan
    // Obtain one at https://etherscan.io/
    apiKey: "YOUR_ETHERSCAN_API_KEY"
  }
};

This is the same configuration used in Hardhat etherscan verification plugin, so it does not conflict with it.

Multiple API keys

To configure different API keys for different networks, add an object under the configuration option like this:

module.exports = {
  etherscan: {
    apiKey: {
        mainnet: "YOUR_ETHERSCAN_API_KEY",
        rinkeby: "YOUR_RINKEBY_ETHERSCAN_API_KEY",
        ropsten: "YOUR_ROPSTEN_API_KEY",
    }
  }
};

Usage

First add an Etherscan's Api Key to the configuration as explained in the previous section.

Then, run the clone task, passing the address of the contract and the network where it's deployed.

npx hardhat clone --network mainnet DEPLOYED_CONTRACT_ADDRESS

To list the supported networks, use the --list-networks flag

npx hardhat clone --list-networks

How it works

The plugin uses Etherscan getsourcecode endpoint to download the source code of a contract. It then creates one or several files depending on how the contract was uploaded.

Supported networks

  • mainnet
  • rinkeby
  • goerli
  • kovan
  • ropsten

Other networks will be added in the future

Final note

The development of this plugin has been inspired by the plugin hardhat-etherscan, and some parts of the code regarding the connection to etherscan have been influenced by its code. Big thanks to the developers.

Also, this is the first npm package and plugin I create. Please, do not hesitate in reaching out with any kind of feedback to improve this plugin and make it as useful as possible.

Thanks !