OpenZeppelin + Remix : Verification on Etherscan fails

Hi Team,

So I have very little Solidity knowledge so have just learnt through YT. I'm getting a
"Error! Unable to generate Contract Bytecode and ABI" when verifying on Etherscan.

I created a standard ERC20 token -> deployed to Remix -> then injected my MetaMask -> complied (no errors) -> launched on mainnet. Contract 0x9cbe55fbdea69cd48d597e3f84368c041ac8c47a was deployed.

Verification is failing:
I flattened in remix -> add 1 line of code at the top to give License (MIT) and then copied all the code.

In Etherscan I try to verify (Contract as above, Single file, MIT license v0.8.20). I add all the code. Optimization: Yes. Remove the Constructor Argument -> publish and I get the below error:

Error! Unable to generate Contract Bytecode and ABI

Compiler debug log:

  • Found the following ContractName(s) in source code : Context, ERC20, ERC20Pausable, IERC1155Errors, IERC20, IERC20Errors, IERC20Metadata, IERC721Errors, MemeMan1, Ownable, Pausable
  • But we were unable to locate a matching bytecode (err_code_2)
  • For troubleshooting, you can try compiling your source code with the Remix - Solidity IDE and check for exceptions

I've tried all different variations, leaving the auto-populated Constructor Argument, etc.

Any tips to debug this?

1 Like

This error means that etherscan was not able to reproduce your build process. It could be caused by a lot of factors. Please refer to the following guides:

1 Like

I've followed this and done it so many different times - still not able to verify. Single file + Flattened code -> Optimisation on and at 200, Pragma solidity ^0.8.20 should match compiler version right? v0.8.20+commit.a1b79de6

I have also tried "EVM Version to target" as Shanghai (default for >=v0.8.20) instead of leaving this at Default.

This is the latest one I tried and failed to verify again:

1 Like

This can match any of the following

  • 0.8.20
  • 0.8.21
  • 0.8.22
  • 0.8.23
  • 0.8.24
  • 0.8.25
1 Like