@medga/hardhat-clone
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

hardhat-clone: Clone on-chain contracts into your hardhat project

hardhat-clone is a plugin of Hardhat smart contract development toolchain. hardhat-clone takes the address of a verified contract deployed on the blockchain (any EVM-compatible blockchain, e.g., Ethereum, Binanace Smart Chain, Optimism, etc.) and clone the contract source into the current Hardhat project. The cloned contracts are reorganized such that it can be compiled together with other contracts in the Hardhat project.

This project is a migrated implementation of forge clone feature of foundry in Hardhat, maintained by MEDGA Team.

Features

@medga/hardhat-clone differs from other similar Hardhat plugins:

  • Clone multiple on-chain contracts into current Hardhat project.
  • Cloned contracts are fully compilable, using the same compiler settings as on chain.
  • Cloned contracts are reusable by other contracts in the Hardhat project (e.g., import as dependency, etc.).

Usage

Install hardhat-clone plugin:

npm i @medga/hardhat-clone

Import hardhat-clone plugin in your Hardhat config file (e.g., hardhat.config.ts):

import '@medga/hardhat-clone'

Clone an on-chain verified contract from Etherscan:

npx hardhat clone --etherscan-api-key <API_KEY> <ADDRESS> <FOLDER>

This command clones the specified contract from Ethereum Mainnet (source provided by Etherscan API) into <FOLDER>, which is a folder path relative to the root of Hardhat project.

Cloning from other EVM-compatible is also possible by specifying the chain ID with --chain.

Tutorial

We offer a tutorial of use @medga/hardhat-clone: TUTORIAL.md.

Technical Design

The technical details can be found in DESIGN.md.

Other Similar Projects

Sponsors

@medga/hardhat-clone is part of MEDGA project, aiming to enhance Ethereum smart contract development and debugging experience. The project is sponsored by:

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.00latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.00
0.0.10

Package Sidebar

Install

npm i @medga/hardhat-clone

Homepage

medga.org

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

498 kB

Total Files

78

Last publish

Collaborators

  • troublor