Can not verify an ERC777 inheriting from OpenZeppelin?

Hi there, I can’t verify my ERC777 contract on Etherscan.
This is the problem I got:

This is ERC777 contract’s source code:

pragma solidity 0.5.16;

import '../node_modules/@openzeppelin/contracts/token/ERC777/ERC777.sol';
import '../node_modules/@openzeppelin/contracts/ownership/Ownable.sol';

 * @title MMM
 * @dev Very simple ERC777 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` or `ERC777` functions.
 * Based on
contract MMM is ERC777,Ownable {

    // TODO: 限制總發行量 5 億
    uint256 public constant _maxSupply = 5 * (10 ** 8) * (10 ** 18);

    modifier noOverflow(uint256 _amt) {
        require(_maxSupply >= totalSupply().add(_amt), 'totalSupply overflow');

    constructor () public ERC777('dMMM', 'dMMM', new address[](0)) {

    function mint(address _address,uint256 _amount) public noOverflow(_amount) onlyOwner {
        _mint(msg.sender, _address, _amount, '', '');


And this is OpenZeppelin-contract version we used:

"dependencies": {
    "@openzeppelin/contracts": "^2.3.0",
    "remixd": "^0.1.8-alpha.14"

Contract Address: 0xF453Ac18fa17b9eC9a76fbF219Ba9fe4612eDd0a

I’ve tried to enable or disable optimization and EVM version Petersburg or Istanbul. All of those not work.

Help me please, thanks so much.



Hi @JosenL,

I can understand your frustration when there are issues with verifying.

Based on the code, you used 0.5.16 version of the compiler, which has a default evm version of istanbul.

What tool did you use to deploy your contract (to see if the default is optimized/non-optimized)?
Is your smart contract in a GitHub repository (to check the code and if there is any informatio about deployment checked in)?
Is the smart contract deployed to a public testnet (to try verifying there)?

What license are you using for your smart contract? (in case you don’t have a testnet version and would like me to try verifying)

Thank you for your reply. I deployed contracts with Remix IDE, I do not sure enable or disable the optimization when I deploying contracts. But I never edit the runs, it kept default value 200.

The code in the topic is the contract that I deployed, no external code. OpenZeppelin version is "@openzeppelin/contracts": "^2.3.0",

Contract address is 0xF453Ac18fa17b9eC9a76fbF219Ba9fe4612eDd0a deployed in mainnet, license can use MIT.

1 Like

Hi @JosenL,

I flattened the contract using this process: Verifying a contract inheriting from OpenZeppelin Contracts

Unfortunately I wasn’t successful. I tried with/without optimization and some different EVM versions.

Are there any reasons other than the compiler version, EVM version, and optimization options that prevent the contract from being verified? @abcoathup

1 Like

Hi @JosenL,

The other issue would be if the code was different from what was deployed.

I haven’t used remixd before, but assume that imports work as per a local package.

Hi @JosenL,

I verified your contract. I checked the bytecode and realized that it didn’t match the pragma so that was the issue.

The contract bytecode ends with: 00050c0032
Which means it was compiled with 0.5.12 (see:

I changed the pragma to 0.5.12 as the existing pragma didn’t match the bytecode, used OpenZeppelin Contracts v2.3.0 and optimization enabled with 200 runs.

Hello @abcoathup
I have the same issue in my contract see if you can help

thank you in advance

Hi, I think you can have a look at this tutorial:

And for the next time, please search at the forum at first, thanks!

1 Like