I went to https://wizard.openzeppelin.com to generate an ERC20 contract and then pasted the contract on Remix and deployed on Goerli. Then, I flattened the same code and tried to verify it on Goerli with the deployed contract but it says...

Compiler debug log:
 Error! Unable to generate Contract Bytecode and ABI
 Found the following ContractName(s) in source code : Context, ECDSA, EIP712, ERC20, ERC20Burnable, ERC20Pausable, ERC20Permit, IERC1155Errors, IERC20, IERC20Errors, IERC20Metadata, IERC20Permit, IERC5267, IERC721Errors, Math, MessageHashUtils, MyToken, Nonces, Ownable, Pausable, ShortStrings, SignedMath, StorageSlot, Strings
 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 compared the bytecodes - the bytecode (what we are looking for) - vs what we got - and they don't match. I even compared the byte code from Remix with the one generated by Etherscan and they still don't match. How come?

I chose to compile and deploy the unflattened code and used the flattened version on Etherscan verification but I thought they should match up, shouldn't they?

I also set the same compiler version and turned on optimization.

Below is the ERC20 code I used from OpenZeppelin Wizard. And the contract on Goerli is https://goerli.etherscan.io/address/0xb1f46ef6ac42e15f7a8bb0cf272ac0b49dbe5204

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";

contract MyToken is ERC20, ERC20Burnable, ERC20Pausable, Ownable, ERC20Permit {
    constructor(address initialOwner)
        ERC20("MyToken", "MTK")

    function pause() public onlyOwner {

    function unpause() public onlyOwner {

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);

    // The following functions are overrides required by Solidity.

    function _update(address from, address to, uint256 value)
        override(ERC20, ERC20Pausable)
        super._update(from, to, value);

UPDATE: I just tried compiling and deploying the flattened code and verification still failed. Btw, I need to enter a wallet address during deployment (initial owner address). Does the bytecode take this into account? Since my original code does not contain my wallet address, could the bytecode be different than the deployed bytecode because of this missing address?

1 Answer 1


I have this EXACT issue right now.. been working on it all day. Did you find a solution or workaround? My code also requires an entry for 'original owner' at deployment. Any update would be appreciated.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.