Verify Upgrades Plugins proxy on Etherscan
I verified AdminUpgradeabilityProxy.sol using the following method:
- (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).
- 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
- Imported
@openzeppelin/contracts@3.1
forAddress.sol
- Removed any other contracts from the
contracts
directory, cleaned the cache and artifacts due to the following:
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 - Setup Buidler Etherscan plugin including my Etherscan API key (in a
secrets.json
): https://buidler.dev/plugins/nomiclabs-buidler-etherscan.html - 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. - 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;
}
}
- Created a file for the arguments:
// arguments.js
module.exports = [
"0x4Ab3A6697DD327FacAe07b1d2C39c96b7bE3a7a8",
"0xe7Db24E9cD3bf8d57F88CFCb09C48AeFDc1666d2",
"0x6057361d000000000000000000000000000000000000000000000000000000000000002a"
];
- Set the compiler version (Solidity 0.6.8) as per the deployed bytecode (which includes the compiler version).
- 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