Cannot auto verify Proxy contract with implementation and ProxyAdmin

I'm trying to auto-verify my upgradable contract with proxies on Ropsten by using overridden task verify:verify in hardhat-upgrades lib but get some errors.

My contract has solidity compiler version of 0.8.10 and after trying to verify I'm getting such error: NomicLabsHardhatPluginError: The contract you want to verify was compiled with solidity 0.8.2, but your configured compiler version is: 0.8.10. I don't know why I'm getting it, if the proxies contracts are already verified on Ropsten network and hardhat-upgrades lib should log message which said that contracts are already verified.

Afterwards, I set version of compiler to 0.8.2 and it doesn't help me. The new error come: NomicLabsHardhatPluginError: The address provided as argument contains a contract, but its bytecode doesn't match any of your local contracts. Still don't know why, because I'm using latest versions of:

"@openzeppelin/contracts": "^4.7.0",
"@openzeppelin/contracts-upgradeable": "^4.7.0",
"@openzeppelin/hardhat-upgrades": "^1.19.0",

Any help would be appreciated.

1 Like

But if I try command npx hardhat verify --network ropsten <address> everything works. So I suppose its problem with verification of Proxy or ProxyAdmin contracts or even with hardhat-upgrades verify task.

Maybe overridden verify task in hardhat-upgrades lib, when gets a proxy address cannot verify any of contracts because of some issue in itself, but when provided address is not a proxy, everything works great.

hardhat-upgrades overrides the verify task, not verify:verify.

So it should be called like:
npx hardhat verify --network ropsten <PROXY_ADDRESS> (note that this should be the proxy address, not implementation address)

The errors about compiler version 0.8.2 that you mentioned would occur if hardhat-etherscan's actual verify task was being called without hardhat-upgrades's override. This is because the proxy contracts deployed by the upgrades plugins were precompiled with solidity 0.8.2 and hardhat-etherscan is trying to verify that directly (which does not work since you may not have the same proxy source code and identical compiler settings in your workspace).

hardhat-upgrades's overriding verify task should avoid this kind of error if it was set up/invoked -- see docs for the verify task if you have issues with the setup.

1 Like

When I said that I use the verify:verify command, I meant that I am trying to verify the contract via"verify:verify", { <proxy contract address> }). Or do you mean that in any case I need to use it like"verify ", { <proxy contract address> }) to use an overridden one?

There is a sample code that I am using to deploy and automatically verify a contract.

Yes, it should be run as"verify", { address: <proxy contract address> })

1 Like

Thanks a lot!!! It works

1 Like


Let me confirm that I've understood it right. The hardhat-etherscan plugin implements a task verify, this task has a subtask with the same name verify. When one needs to verify a regular contract programmatically, he must call the subtask. However, the hardhat-upgrades override the hardhat-etherscan verify task without subtasks, and when one needs to verify a upgradeable contract, he has to call the "new" overriden verify task.

Is this right?

Thanks a lot,

Hi @fabianorodrigo, that is correct at the moment, and I think it can be improved by having the Hardhat Upgrades plugin override the verify:verify subtask. Thanks for bringing this up. I've opened a GitHub issue here.

1 Like

Update: this has been fixed in the hardhat-upgrades plugin (version 1.20.1 or later). When verifying programmatically, you would now need to call verify:verify (which makes this consistent with hardhat-etherscan) instead of verify. See docs.