Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardhat init by cloning on-chain verified contracts #5397

Open
Troublor opened this issue Jun 14, 2024 · 3 comments
Open

hardhat init by cloning on-chain verified contracts #5397

Troublor opened this issue Jun 14, 2024 · 3 comments
Assignees
Labels
status:ready This issue is ready to be worked on

Comments

@Troublor
Copy link
Contributor

Troublor commented Jun 14, 2024

Describe the feature

We propose to bring the clone on-chain verified contracts feature to hardhat to facilitate daily development, learning, and experimenting of Ethereum developers.

Motivation

Currently hardhat init creates only sample projects.
This creates an obstacle on blockchain developers, who may want to re-compile the contracts of popular DApps, customize it, deploy in a local chain, write hardhat tests/tasks with the contract, etc.

Proposal

We propose to extend the hardhat init command by providing one additional question during the project creation guide, e.g., Do you want to clone an existing on-chain contract?, to allow users to opt into the clone feature.
This will dump contract source code from Etherscan or other sources into the hardhat project being created, and most importantly, the hardhat configuration will be adjusted according to the compilation settings for the on-chain contract.

We welcome any comments and suggestions helping us improve this feature and contribute to a better smart contract development and debugging experience.

Disclaimer

We (@ZhangZhuoSJTU and I) are planning to bring the clone on-chain verified contracts feature to hardhat, just as we did for foundry: foundry-rs/foundry#7576.
More information can be found at foundry-rs/foundry#7575
The forge clone feature has received great feedback in the community. https://x.com/troublor/status/1780984367931695256
Now we are trying to bring this to hardhat.

Search terms

clone, init

@Troublor
Copy link
Contributor Author

Would it be a good choice to fork the hardhat repo and modify the code of hardhat init's createProject() function?

Is the plugin capable of achieving this goal?

@alcuadrado
Copy link
Member

Hey @Troublor! 👋

A plugin can't really customize the init functionality, but it can customize the config and define new tasks, so I think a hardhat clone <address> workflow would be possible, and easier to adapt by existing users.

@Troublor
Copy link
Contributor Author

@alcuadrado Thanks for the clarification!
The hardhat clone <address> workflow is definitely fine with us.

Is hardhat clone possible with plugin?
Correct me if I am wrong:
To my understanding, the plugin only works on an existing hardhat project, while hardhat clone needs to work as a global command (since it is used to create a hardhat project).
So I think the solution is to directly add the clone subcommand to the hardhat core CLI.

@kanej kanej added status:ready This issue is ready to be worked on and removed status:triaging labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
Status: Backlog
Development

No branches or pull requests

3 participants