Verification of UUPS Upgradeable Contracts Failing

I am trying to verify 3 UUPS upgradeable contracts on Ropsten Etherscan.
I am using this pattern to get the addresses for their implementation contracts:

const proxyAddress = contractProxyAddress
const implementationAddress = await upgrades.erc1967.getImplementationAddress(proxyAddress)

I am using the returned implementation address and an empty constructor args array here:

await hre.run("verify:verify", {
       address: contractAddress,
       constructorArguments: constructorArgs,
    });

This is the failed verification message:

deployment file being verified:  ./.deployments/ropsten/ropsten-1654132332519000.json
----------
VaultFactory: 0x070c58d8720b18A5763c1e24FE30d6AA77F86810
----------
Nothing to compile
Creating Typechain artifacts in directory typechain for target ethers-v5
Successfully generated Typechain artifacts!
Compiling 1 file with 0.8.11
Successfully submitted source code for contract
contracts/vault/VaultFactory.sol:VaultFactory at 0x070c58d8720b18A5763c1e24FE30d6AA77F86810
for verification on the block explorer. Waiting for verification result...

We tried verifying your contract VaultFactory without including any unrelated one, but it failed.
Trying again with the full solc input used to compile and deploy it.
This means that unrelated contracts may be displayed on Etherscan...

Successfully submitted source code for contract
contracts/vault/VaultFactory.sol:VaultFactory at 0x070c58d8720b18A5763c1e24FE30d6AA77F86810
for verification on the block explorer. Waiting for verification result...

NomicLabsHardhatPluginError: The contract verification failed.
Reason: Fail - Unable to verify
    at SimpleTaskDefinition.verifySubtask [as action] (/Users/node_modules/@nomiclabs/hardhat-etherscan/src/index.ts:332:9)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I have tried all the suggestions here:
How to verify a contract on Etherscan/BscScan/PolygonScan

:computer: Environment

"@nomiclabs/hardhat-ethers": "^2.0.1",
"@nomiclabs/hardhat-etherscan": "^3.0.4",
pragma solidity ^0.8.11;

Would appreciate any insight to get this resolved!

1 Like

"Unable to verify" is a generic error from hardhat-etherscan indicating that verification failed for some reason, usually due to something not matching with the verification parameters (e.g. constructor args).

Since you are verifying the implementation itself, this is no different than verifying regular contracts on hardhat-etherscan so I don't think we can help much further.

Note that to verify the actual proxy contracts, you can use the recently added verify task in the Hardhat Upgrades plugin. But you would still need to resolve the issue above to verify your implementation.

1 Like

Please can you confirm if my understanding of process for verifying UUPS upgradeable contracts is correct:

  • since these are upgradeable contracts, they would have no constructor arguments
  • proxy and implementation should both be verified
  • I would need to manually verify the proxy first
  • I would need to manually verify all the openzeppelin inherited contracts
  • use the Hardhat Upgrades plugin verify task
    Is anything missing?

If you use the Hardhat Upgrades plugin verify task, it will do all of the above automatically. Just run the command on the proxy address, and it will automate verification of the proxy and your implementation (which includes all inherited OpenZeppelin contracts). No need to manually verify.

You are right that they usually have no constructor arguments. See this note in the verify task's documentation:

Note that you do not need to include constructor arguments for the verify task if your implementation contract only uses initializers. However, if your implementation contract has an actual constructor with arguments (such as to set immutable variables), then include constructor arguments in the command according to hardhat-etherscan’s usage documentation.

1 Like