How to verify upgradable contract on ropsten in etherscan?

Hello everyone,

I managed to create an upgradable contract and deploy it to ropsten with zos. I’m now trying to verify it manually on etherscan, I’m using truffle-flattener to generate a flatten version of the contract but when I try to verify it etherscan says:

Sorry! The Compiled Contract ByteCode for ' **Gateway** ' does  **NOT**  match the Contract Creation Code for Address [0x9afb3cec8889cac85110f5732e0d9d22eeb4889d](https://ropsten.etherscan.io/address/0x9afb3cec8889cac85110f5732e0d9d22eeb4889d).
 Found the following ContractName(s) in source code: DexI, Gateway, GlobalVar, IERC20, Initializable, Ownable. 

Unable to Verify Contract Source Code.

What am I missing?

hi @Alexintosh welcome to the community :slight_smile: I am tagging @frangio to check this for you. In the meantime would like to hear more about you on this thread.
https://forum.openzeppelin.com/t/introduce-yourself-here/88/116
Please do drop by to say hi :slight_smile:

1 Like

Hey @Alexintosh! Have you tried directly with the zos verify command? It will ask you for an etherscan API key to run the verification, but it should handle everything automatically (flattenning included) for you. The only caveat is that it does not support external solidity libraries at the moment, but if that is not your case, give it a shot!

Yeah I tried with zos verify --network ropsten --api-key <KEY> <NAME Contract> but I get:
Invalid network. Currently, etherchain supports only mainnet

Make sure to add --remote etherscan, otherwise zos verify defaults to etherchain instead of etherscan.

1 Like

@Alexintosh any luck? :slight_smile:

I managed thanks guys!

1 Like

According to documentation, there are two settings for optimization available in zos verify:

--optimizer
--optimizer-runs

Which role does it play for verification on Etherscan and which arguments are best practices here?

1 Like

Hi @itinance

According to the ZeppelinOS documentation the default for zos compile is optimizer off and optimizer-runs (only if optimizer enabled) is 200.

https://docs.zeppelinos.org/docs/cli_compile.html
--optimizer [on|off] enables compiler optimizer (value is written to configuration file for future runs, defaults to off)

--optimizer-runs [runs] specify number of runs if optimizer enabled (value is written to configuration file for future runs, defaults to 200)

The verify settings need to match the compile settings to allow verification on Etherscan, otherwise the Etherscan generated bytecode doesn't match what was deployed.

Truffle turned off optimization by default in late 2017 https://github.com/trufflesuite/truffle/issues/543
I don't know if best practices have changed, but ZeppelinOS has optimizer off by default.

If you need more information, suggest creating a new topic.

1 Like