Error verifying proxy with plugin @nomiclabs/hardhat-etherscan

Hi @Skyge,

Thanks for checking out the tutorial and the all the details of what you used.

I had trouble verifying the proxy as I originally had OpenZeppelin Contracts 3.1 rather than OpenZeppelin Contracts 3.2 as a dependency. I verified in a separate project.

I did the following using your Token contract and a slightly modified hardhat configuration:

Deploy

$ npx hardhat run --network kovan scripts/deploy.js
Creating Typechain artifacts in directory types for target ethers-v5
Successfully generated Typechain artifacts!
Deploying contracts with the account: 0xEce6999C6c5BDA71d673090144b6d3bCD21d13d4
Account balance: 100000000000000000
Token address: 0x639E41d0E23b56b91deA5dC39A92A3c58Dbf0062

Verify Implementation (Token.sol)

Implementation address obtained from .openzeppelin/kovan.json

$ npx hardhat verify --network kovan 0x4E37CC7B6d8097a22150CDFa7dcC133C245D5979
Nothing to compile
Creating Typechain artifacts in directory types for target ethers-v5
Successfully generated Typechain artifacts!
Successfully submitted source code for contract
contracts/Token.sol:Token at 0x4E37CC7B6d8097a22150CDFa7dcC133C245D5979
for verification on etherscan. Waiting for verification result...
Successfully verified contract on etherscan

https://kovan.etherscan.io/address/0x4E37CC7B6d8097a22150CDFa7dcC133C245D5979#code


When we first deploy three contracts are deployed:

  1. Implementation: https://kovan.etherscan.io/tx/0xd3520b35bac0319888b945bc50c58572647ecb5e2ac7c69d94c92d62b611afc0
  2. ProxyAdmin: https://kovan.etherscan.io/tx/0x1050022949a2470a771e0fb63657b81a6756cb52c85edd945d1968e8490db269
  3. Proxy: https://kovan.etherscan.io/tx/0x2d398a2677df78b980cd58f1226aa7447f1655ad6efef345e59c806ece393f46

Rerunning deploy only deploys a proxy, as there is only one ProxyAdmin per network deployed by your project and the implementation contract has already been deployed:

  1. Proxy:
    https://kovan.etherscan.io/tx/0xc541cae6fd6547f4d2fb39716ee977fe5083b766498f9ae06ddac5d507cd0462

_From: https://docs.openzeppelin.com/upgrades-plugins/1.x/faq#what-is-a-proxy-admin_

A ProxyAdmin is a contract that acts as the owner of all your proxies. Only one per network gets deployed.

$ npx hardhat run --network kovan scripts/deploy.js
Creating Typechain artifacts in directory types for target ethers-v5
Successfully generated Typechain artifacts!
Deploying contracts with the account: 0xEce6999C6c5BDA71d673090144b6d3bCD21d13d4
Account balance: 97484402000000000
Token address: 0x903303BfA4Def0Fc4F474b965DC81F33CB87b550

I verified the proxy and the ProxyAdmin using Hardhat Etherscan plugin, similar to: Verify Upgrades Plugins proxy on Etherscan but using OpenZeppelin Contracts 3.2

Verify ProxyAdmin

$ npx hardhat verify --network kovan 0xe5452ae84dd4b374e3bc6a3e5b3a63584d619c83
Nothing to compile
Successfully submitted source code for contract
contracts/proxy/ProxyAdmin.sol:ProxyAdmin at 0xe5452ae84dd4b374e3bc6a3e5b3a63584d619c83
for verification on etherscan. Waiting for verification result...
Successfully verified contract on etherscan

https://kovan.etherscan.io/address/0xe5452ae84dd4b374e3bc6a3e5b3a63584d619c83#code

Verify Proxy

(using OpenZeppelin Contracts 3.2)

$ npx hardhat verify --constructor-args arguments.js --network kovan 0x639E41d0E23b56b91deA5dC39A92A3c58Dbf0062
Compiling 3 files with 0.6.8
Compilation finished successfully
Successfully submitted source code for contract
contracts/proxy/AdminUpgradeabilityProxy.sol:AdminUpgradeabilityProxy at 0x639E41d0E23b56b91deA5dC39A92A3c58Dbf0062
for verification on etherscan. Waiting for verification result...
Successfully verified contract on etherscan

https://kovan.etherscan.io/address/0x639E41d0E23b56b91deA5dC39A92A3c58Dbf0062#code


I will have to find out how to write typescript to deploy. I have created a new topic for this: How to write the Typescript to deploy?

1 Like