Verify Upgrades Plugins proxy on Etherscan

Verify Upgrades Plugins proxy on Etherscan

I verified AdminUpgradeabilityProxy.sol using the following method:

  1. (Optional) For ease I deployed a Box contract using the Upgrades Buidler plugin (though assuming you have already deployed an upgradeable contract you don’t need to do this).
  2. In a Buidler project, copied the AdminUpgradeabilityProxy.sol, UpgradeabilityProxy.sol, Proxy.sol contracts from https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/%40openzeppelin/upgrades-core%401.1.0/packages/core/contracts/proxy
  3. Imported @openzeppelin/contracts@3.1 for Address.sol
  4. Removed any other contracts from the contracts directory, cleaned the cache and artifacts due to the following:
    :warning: There is currently an issue using the Buidler Etherscan plugin which due to an issue with Solidity includes all compiled files in the verification: https://github.com/nomiclabs/buidler/issues/804
  5. Setup Buidler Etherscan plugin including my Etherscan API key (in a secrets.json): https://buidler.dev/plugins/nomiclabs-buidler-etherscan.html
  6. From my previous deploy of the upgradeable contract, got the address of the implementation contract and proxy admin from .openzeppelin/kovan.json and from the deploy script the arguments to initialize the proxy.
  7. Encoded the initialize (I initialized with the store function passing 42 as a parameter
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

contract MyContract {
    
    function calculate() public pure returns (bytes memory) {
        uint256 value = 42;
        bytes memory payload = abi.encodeWithSignature("store(uint256)", value);

        return payload;
    }
}
  1. Created a file for the arguments:
// arguments.js
module.exports = [
    "0x4Ab3A6697DD327FacAe07b1d2C39c96b7bE3a7a8",
    "0xe7Db24E9cD3bf8d57F88CFCb09C48AeFDc1666d2",
    "0x6057361d000000000000000000000000000000000000000000000000000000000000002a"
  ];
  1. Set the compiler version (Solidity 0.6.8) as per the deployed bytecode (which includes the compiler version).
  2. Verified:
$ npx buidler verify --constructor-args arguments.js --network kovan 0x20E9516E8Ea6e6259FaD9b456F65205C049C3AeD
Compiling...
Successfully submitted source code for contract
contracts/proxy/AdminUpgradeabilityProxy.sol:AdminUpgradeabilityProxy at 0x20E9516E8Ea6e6259FaD9b456F65205C049C3AeD
for verification on etherscan. Waiting for verification result...
Successfully verified contract on etherscan

I verifed ProxyAdmin using the following method:

  1. in a Buidler project, copied the proxy contracts from https://github.com/OpenZeppelin/openzeppelin-upgrades/tree/%40openzeppelin/upgrades-core%401.1.0/packages/core/contracts/proxy
  2. Imported @openzeppelin/contracts@3.1
  3. Removed any other contracts from the contracts directory, cleaned the cache and artifacts.
  4. Setup Buidler Etherscan plugin including my Etherscan API key (in a secrets.json): https://buidler.dev/plugins/nomiclabs-buidler-etherscan.html
  5. Set the compiler version (Solidity 0.6.8) as per the deployed bytecode (which includes the compiler version).
  6. Verifed:
$ npx buidler verify --network mainnet 0xdea1f88a2cf4fcf467b54c37f765aad1380d0f60
Compiling...
Successfully submitted source code for contract
contracts/proxy/ProxyAdmin.sol:ProxyAdmin at 0xdea1f88a2cf4fcf467b54c37f765aad1380d0f60
for verification on etherscan. Waiting for verification result...
Successfully verified contract on etherscan

A post was split to a new topic: Verify AdminUpgradeabilityProxy on Ropsten