Hardhat+Etherscan contract verification from deployment failed #490
Habeebullahi01
started this conversation in
General
Replies: 1 comment
-
Thanks for this! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is just a tip in case your contract didn't get verified on Etherscan after you included the
verify
task in yourdeploy.js
file.Situation
You added the code to verify your contract on etherscan into your
deploy.js
file (or anywhere). You run the code, and it exits with no error and everything is fine.You view the contract on etherscan and it's not verified.
Reason
Hardhat compiles the
SimpleStorage.sol
using the compiler version stated in thehardhat.config.js
file. Etherscan seems to compile the contract using the compiler version stated in theSimpleStorage.sol
file. In this case, Etherscan will compile it with the latest compiler version (0.8.15 at the time of writing). The compiled bytecode that was created by Hardhat after compilation on your local machine will be compared to the bytecode that is produced by Etherscan after compiling on their own end. If compiler versions are different, resulting bytecodes will also be different.This maybe because your
SimpleStorage.sol
does not specify the version of compiler to use, it has a range likepragma solidity ^0.8.8
.Solution
Hardhat and Etherscan have to compile the contract with the same compiler version. There are 2 ways to achieve this:
hardhat.config.js
as to which compiler version to use.hardhat.config.js
. You can read more about this hereI hope this helps to solve your problem.
Beta Was this translation helpful? Give feedback.
All reactions