Unable to verify proxy contract to use defender

I’ am compiling the contract with Hardhat and solidity version 0.8.0
I am deploying the contract with ethers under a hardhat task.
When i try to verify that contract. I get this error.

Error in plugin @nomiclabs/hardhat-etherscan: The bytecode retrieved could not have been generated by any of the selected compilers.
The expected version is 0.6.12.
The selected compiler version is: 0.8.0

Possible causes are:

  • Wrong compiler version selected in hardhat config.
  • The given address is wrong.
  • The selected network (rinkeby) is wrong.

I’m not sure where it is getting this 0.6.12 from.

My complete code can be found here

To reproduce

npm install

npx hardhat compile

npx hardhat deploy

npx hardhat verify --network rinkeby 0x30F7220cA0b1072ef55144E355Ff7c2d9ff624B4 “argument 1 address”

The argument 1 is the address passed in the initializer.

It’s pretty much based on defender example.

To test it you will need an .env file with the folowing

MNEMONIC = a mnemonic
INFURA_ID = infura ID
ETHERSCAN = Etherscan API Key

3 Likes

Hi @madeindreams,

The proxy contract is generally verified on public networks. I assume you are using 1.6.0 version of Upgrades Plugins.

The proxy contract is precompiled, (https://github.com/OpenZeppelin/openzeppelin-upgrades/blob/%40openzeppelin/upgrades-core%401.6.0/packages/core/contracts/proxy/AdminUpgradeabilityProxy.sol)
and is currently using Solidity 0.6

The proxy was compiled with Solidity 0.6.12

I will let you know when this has been verified.

2 Likes

So I guess this also explains why I can’t see the proxy verification page on etherscan.

Thank you @abcoathup

1 Like

@abcoathup I’m not sure I totally get it. Does OZ have to trigger a verification for each proxy on each network?

The version I’m using are

"@openzeppelin/contracts": "^4.0.0",
"@openzeppelin/contracts-upgradeable": "^4.0.0",
"@openzeppelin/hardhat-upgrades": "^1.6.0",

The contracts are all 0.8.0. Is it a matter of my versions or simply the proxy versification process?

2 Likes

Hi @madeindreams,

The proxy contract is precompiled, and is written in Solidity 0.6. This is independent of your implementation contract which can use Solidity 0.8.

We can verify the contract on each network, which then verifies all the proxies with the same bytecode, so from the same release 1.6.0.

3 Likes

The contracts are verified now. Sorry about the inconvenience. Should be automated very soon.

2 Likes

Hi @madeindreams,

If you verify your implementation contract, you can then interact with your upgradeable contract on Etherscan.

1 Like

Awesome Thank you very much team!

1 Like

Well not sure which one is it?
If I deploy and got to ehterscan I can see it’s a proxy.
If i try to verify it from Etherscan is get his error.

The proxy contract verification completed with the message:

The implementation contract at 0x75dec8693ac1878296a3ef3d20ef32a5fdb5e067 does not seem to be verified.

Is that the one I have to verify? I wouldn’t know where to start. I don’t even know what is this address.

This contract does not seem to be a proxy or at least Etherscan don’t see it as a proxy.

This would be my proxy I’m trying to verify.

0x5808197Bb9c046158e566e23CE0C18992FEA6011

I will try and bring everything down to the same version to make sure that this is not the issue.

2 Likes

Hi @madeindreams,

Your implementation contract is the Solidity code you deployed as an upgradeable contract, it is the contract your proxy points to.

I assume it is MDEV:

You can verify it just like any other contract.

2 Likes

Ok so I guess it’s the hardhat verify plugin that is not working like I was expecting.

I have yet to be able to verify it using Hadhat. I did not try with truffle on the upgradeable ones yet since I was planning to use Hardhat.

If I try to verify it using Hardhat, with;

npx hardhat verify --network rinkeby “my contract address” “MyAddress”

It is complaining that the proxy is in solidity 0.6.12.

This is the last thing I’m struggling with to get a complete solution to deploy and verify with hardhat. And I would really like to get this going. Do you have any clue on what I could be missing?

I think I’m going to have to open a bounty for this one!

2 Likes

Hi @madeindreams,

You only need to verify the implementation. So use the address of the implementation contract:

npx hardhat verify --network rinkeby 0x75dec8693ac1878296a3ef3d20ef32a5fdb5e067

It would only complain about the proxy if you were trying to verify the proxy address which is already verified and was compiled with Solidity 0.6.12

1 Like

Your my hero!

Thank you so much! So we have to verify the adresse of the implementation, not the proxy. Thing is we are used to get the contract address back and verify that since we use to code the proxy.

So the confusing part is how do we get this address after deployment? I was able to retrieve that address trying to verify the proxy! And round we go!

Glad you solved it.

3 Likes