Issue Verifying Implementation Smart Contract on etherscan

Hello, I am trying to verify an implementation smart contract, however I get the following error(s), it was deployed using hardhat deployProxy, all 3 contracts are deployed and working fine.

What I've done:

  1. After deploying, I copy-paste the .sol file to Remix, where I flatten the file, then I copy paste to etherscan and add // SPDX-License-Identifier: MIT at the top, since I receive an error if I don't, saying it's not found.
  2. Fill in the settings, optimization 200 runs, 0.8.2 complier, MIT license
  3. Click verify and receive error...

What I've checked:

  1. The code from here is identical to "deployedBytecode": from artifacts/contract/ json file.
  2. The code from etherscan compiler output "ByteCode (what we are looking for) is identical to "bytecode" from he same json file above EXCEPT it has this extra at the end a26469706673582212208fd45fec4fd2404bbdee05ddd55fd9b30a80a5c1b9d089bf70b72b233847c35064736f6c63430008020033
  3. The bytecode from etherscan complier "- vs what we got -" #2 isn't found in the json file mentioned above, from artifacts inside hardhat project.

Extra info:
I tried verifying with etherscan-verify however I get an error in the console saying something along the lines that "did you change any files in the smart contract, wrong bytecode", I don't recall exactly, I'm willing to verify manually obviously!

Thank you very much!

If you the hardhat to deploy contracts, so why not use the plugin in the hardhat to verify your contract.
Have a look at this plugin: hardhat-etherscan | Hardhat

Hello, I am using that plugin, however I get this error:

Error in plugin @nomiclabs/hardhat-etherscan: The address provided as argument contains a contract, but its bytecode doesn't match any of your local contracts.

Possible causes are:
  - Contract code changed after the deployment was executed. This includes code for seemingly unrelated contracts.
  - A solidity file was added, moved, deleted or renamed after the deployment was executed. This includes files for seemingly unrelated contracts.
  - Solidity compiler settings were modified after the deployment was executed (like the optimizer, target EVM, etc.).
  - The given address is wrong.
  - The selected network (polygon) is wrong.

I just deploy contract, copy paste address inside command, I change NOTHING...

Issue solved, I was using the smart contract address of the proxy, the address you get in the console when you deploy for example, and obviously I needed the address of the implementation which I got from etherscan!

1 Like