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

Update hardhat package plugins and add hardhat-verify #637

Merged
merged 13 commits into from
Jan 8, 2024

Conversation

metoinside
Copy link
Contributor

@metoinside metoinside commented Dec 1, 2023

EDIT : Please just to #637 (comment) for actual changes

Description

As recorded with #314, we're unable to verify in some networks.
It was returning an error as like below scrollSepolia, arbitrumSepolia, polygonZkEvmTestnet
image

That's because of hardhat-etherscan plugin which we're actively using and it is depreciated.
Official docs are suggesting to migrate into hardhat-verify and this PR is trying to do it.

As we migrated to the new library, we had to upgrade some dependencies and I tried to have a minimal impact.
For example, we can now deploy sepolia right away but we need to add custom configuration and the keys for the scrollSepolia.
It means after this PR is approved, we need to update the documentation on how to use it.

Additional Information

Related Issues

Closes #314

After this PR, you can now verify a smart contract with
yarn verify --network [networkOfYourChoice] <address> [constructorParameters]

We have verified these contracts

This is going to be my first PR, therefore please feel free to open a discussion or give feedback to improve

Your ENS/address: 0x63191383EDbd8531C442868d87555f1EA2f6ad4E

@technophile-04
Copy link
Collaborator

Hey thanks @metoinside for this 🙌,

I think there is some confusion with hardhat-etherscan vs etherscan-verify. Although we have hardhat-etherscan as our dependency we are actually using etherscan-verify which goes in hand with hardhat-deploy for verification of contracts.

Some newer chains are not supported with ethersscan-verify but you can add manually the api key and config for that particular network as mentioned in hardhat-deploy readme. The same is the case with hardhat-verify where you need to manually add config for that chain if not supported.


Coming to this PR (using hardhat-verify for verification) :

I like it since it supports newer chains (atleast I think chains that uses etherscan it support them without extra config nd by just updating api-key) 🙌

yarn verify --network [networkOfYourChoice] <address> [constructorParameters]

The only thing I don't like is update to verify command where you need to enter contractAddress and constructor params. but we can't do anything about it :(

Maybe we should also add an programmatical verification example in 00_deploy_your_contrac.ts similr to what we had in SE-1

https://github.com/scaffold-eth/scaffold-eth/blob/79173204dbe6793cda11199bedfb86317b806188/packages/hardhat/deploy/00_deploy_your_contract.js#L71

cc @damianmarti @carletex for suggestions 🙌


Also incase if we don't go with hardhat-verfiy (for now) if etherscan-verify seems better , I will merge this PR in #644 since their we are removing hardhat-deploy

@damianmarti
Copy link
Collaborator

Hey thanks @metoinside for this 🙌,

I think there is some confusion with hardhat-etherscan vs etherscan-verify. Although we have hardhat-etherscan as our dependency we are actually using etherscan-verify which goes in hand with hardhat-deploy for verification of contracts.

Some newer chains are not supported with ethersscan-verify but you can add manually the api key and config for that particular network as mentioned in hardhat-deploy readme. The same is the case with hardhat-verify where you need to manually add config for that chain if not supported.

Coming to this PR (using hardhat-verify for verification) :

I like it since it supports newer chains (atleast I think chains that uses etherscan it support them without extra config nd by just updating api-key) 🙌

yarn verify --network [networkOfYourChoice] <address> [constructorParameters]

The only thing I don't like is update to verify command where you need to enter contractAddress and constructor params. but we can't do anything about it :(

Maybe we should also add an programmatical verification example in 00_deploy_your_contrac.ts similr to what we had in SE-1

https://github.com/scaffold-eth/scaffold-eth/blob/79173204dbe6793cda11199bedfb86317b806188/packages/hardhat/deploy/00_deploy_your_contract.js#L71

cc @damianmarti @carletex for suggestions 🙌

Also incase if we don't go with hardhat-verfiy (for now) if etherscan-verify seems better , I will merge this PR in #644 since their we are removing hardhat-deploy

Thanks @metoinside !!

I think hardhat verify has more features than ethersscan-verify, like linking to libraries (but maybe I'm wrong now, I'm not sure if ethersscan-verify added this feature).

And yes! I think will be useful to add an example on how to add a verification with code in the deployment script.

@technophile-04 technophile-04 changed the title Verify smart contracts with hardhat-verify Update hardhat package plugins and add hardhat-verify Jan 5, 2024
@technophile-04
Copy link
Collaborator

Update :

  1. Updated all the necessary hardhat package plugins to the latest version (this was also necessary to make hardhat-verify work properly) also its been long time since we updated them

  2. Didn't remove etherscan-verfiy since I feel it nicely integrates with harhdat-deploy workflow like running yarn deploy to deploy all contracts and yarn verify to verify all deployed contracts in on go. Discussed this with Carlos the other day, to keep both if people faces issue with it they can always fallback to hardhat-verfiy but would love to know other thoughts too 🙌

Once we merge this we can also a couple of lines about hardhat-verify in https://docs.scaffoldeth.io/deploying/deploy-smart-contracts#4-verify-your-smart-contract

@rin-st
Copy link
Collaborator

rin-st commented Jan 6, 2024

Thanks @metoinside and @technophile-04 ! Tested it and everything works fine! But I think we need to add additional script to package.json for verifying with hardhat-verify. Not sure about naming though, what about leaving verify as it is and add new script hardhat-verify: hardhat verify? Or hardhat:verify and hardhat:etherscan-verify? But last will remove previous verify script so it's not so good

@technophile-04
Copy link
Collaborator

Ohh yes! Added it at 2dc40bb,

"verify": "hardhat etherscan-verify",
"hardhat-verify": "hardhat verify"

Kept it like above, I think default verfiy as etherscan-verify is nice due its simplicity and advance users can always use hardhat-verify script if default verfiy script doesn't work.

Copy link
Collaborator

@rin-st rin-st left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

Copy link
Member

@carletex carletex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff, thanks all!

Also created an issue so we document it on the docs: scaffold-eth/se-2-docs#49

@carletex carletex merged commit 2dc4a3b into scaffold-eth:main Jan 8, 2024
1 check passed
@damianmarti
Copy link
Collaborator

Great improvement!! Thanks!

This was referenced Jan 14, 2024
@github-actions github-actions bot mentioned this pull request Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use hardhat verify instead of hardhat etherscan-verify on yarn verify
5 participants