Please Help, Trying to Verify Wizard Generated ERC20 for 3 Days

Hi, I Super Appreciate Your Help, on https://docs.openzeppelin.com/contracts/4.x/wizard

after checking the options “Burnable”, “Pausable”, “Snapshots”, “Permit”, “Roles”, then clicked “Open in Remix”, In Remix Added the Etherscan Verification Plugin, after compiling, the contract successfully verified, but then after deploying on Mainnet, etherscan.io will not verify it.

1st error was saying could not import files, tried a few methods from a few discussions including flattening the file, added the flattening plugin from remix and then the new errors were:

  1. too many licenses, solution: kept the top MIT license and removed all the other licenses, that worked

  2. “definition of base has to precede definition of derived contract” files were not in order, here is the shuffling I have been trying to do with still need help please:

// File: @openzeppelin/contracts/token/ERC20/ERC20.sol
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// File: contract-18cc8a4dad.sol
// File: @openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol
// File: @openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol
// File: @openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol
// File: @openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol
// File: @openzeppelin/contracts/security/Pausable.sol
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
// File: @openzeppelin/contracts/utils/introspection/ERC165.sol
// File: @openzeppelin/contracts/access/AccessControl.sol
// File: @openzeppelin/contracts/utils/Counters.sol
// File: @openzeppelin/contracts/utils/math/Math.sol
// File: @openzeppelin/contracts/utils/Arrays.sol
// File: @openzeppelin/contracts/utils/cryptography/ECDSA.sol
// File: @openzeppelin/contracts/utils/cryptography/draft-EIP712.sol
// File: @openzeppelin/contracts/utils/Context.sol

Now on the 3rd day on trying to verify, I went back to the unflattened file and realized I could add “// File: @openzeppelin” infront of the files for them to import (I think), that removed the import error but now after 3 days of errors, the new error after reverting to the unflattened file: "ParserError: Expected pragma, import directive or contract/interface/library/struct/enum/constant/function definition.

here is the code:

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

// File: @openzeppelin/contracts/token/ERC20/ERC20.sol";
// File: @openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
// File: @openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol";
// File: @openzeppelin/contracts/access/AccessControl.sol";
// File: @openzeppelin/contracts/security/Pausable.sol";
// File: @openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";

contract MyToken is ERC20, ERC20Burnable, ERC20Snapshot, AccessControl, Pausable, ERC20Permit {
bytes32 public constant SNAPSHOT_ROLE = keccak256(“SNAPSHOT_ROLE”);
bytes32 public constant PAUSER_ROLE = keccak256(“PAUSER_ROLE”);

constructor()
    ERC20("My Token", "MTOKEN")
    ERC20Permit("My Token")
{
    _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
    _setupRole(SNAPSHOT_ROLE, msg.sender);
    _setupRole(PAUSER_ROLE, msg.sender);
    _mint(msg.sender, 1000000000 * 10 ** decimals());
}

function snapshot() public {
    require(hasRole(SNAPSHOT_ROLE, msg.sender));
    _snapshot();
}

function pause() public {
    require(hasRole(PAUSER_ROLE, msg.sender));
    _pause();
}

function unpause() public {
    require(hasRole(PAUSER_ROLE, msg.sender));
    _unpause();
}

function _beforeTokenTransfer(address from, address to, uint256 amount)
    internal
    whenNotPaused
    override(ERC20, ERC20Snapshot)
{
    super._beforeTokenTransfer(from, to, amount);
}

}

I super Appreciate your help

Hello developement, Welcome to the forums.

Have you been able to verify other contracts in the past on Remix?

You might need to follow some guides on how to do this for your dev environment.

Hi Tsushima, I appreciate your response, the wizard generated code verified with the remix etherscan plugin, but not on the actual etherscan.io, I respect & love that many of these wizards/plugins are new but as a new user following the steps from wizard > to > remix > to > etherscan, the steps don’t work and now 5th day searching many forums & even inviting devs to solve verifying the wizard generated code, freelancers are also having no solution, is there a code that imports these files that can be verified on Etherscan please?

import “@openzeppelin/contracts/token/ERC20/ERC20.sol”;
import “@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol”;
import “@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol”;
import “@openzeppelin/contracts/access/AccessControl.sol”;
import “@openzeppelin/contracts/security/Pausable.sol”;
import “@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol”;

what is a sample code to put on etherscan.io that works?
Thank you very much
MG

I’m sorry I cannot be more help. The problem is that I am on a different dev environment.

I put my code in here, with minimal changes using hardhat.

The only thing I changed was the " to ’
in the lines

bytes32 public constant SNAPSHOT_ROLE = keccak256('SNAPSHOT_ROLE');
bytes32 public constant PAUSER_ROLE = keccak256('PAUSER_ROLE');

I also changed how I imported those files.

You can see my deployed and verified code here.

1 Like

Thank you very much, you have been helpful, I appreciate it, I followed the link you sent for the Sourcify plugin on remix, that plugin was able to successfully Fetch the contract and Said it was verified already on 4/26 and when it gave me the link to get the verified code https://repo.sourcify.dev/contracts/full_match/1/0xc9b929079ab56184b73dbab3b36c3c5183d799c8 that link says the page is not working?

I looked at your verified code, but it is multi file and it looks similar to the same format that I get the errors saying can not import, on full 7 day week of trying, not including the month of wanting to make a token & now finally got to mainnet & paid gas fees but now can’t see token on mainnet because cant verify it, is there a sample single file is there a good place besides fiverr or upwork to find a teacher to help create a token? thank you very much, appreciated

It is multiple files because you are importing multiple files using import “@openzeppelin/contracts/token/ERC20/ERC20.sol”; When verifying it has to verify that too, which is why using a plugin is very helpful.

Hi Tsushima, you’re right, thank you, the Sourcify plugin is great, I found why the link was not working, the address had to be converted to checksum

But after I converted the address & uploaded all 17 files to Etherscan.io for verification, I still get the import errors, do I have to change the codes to import in all 17 files (all of them return the import error) and if so, what is the right way to write the code for it to import? Do I include http://github.com/ I tried so many ways, can anyone help? Thank you

ParserError: Source “utils/Context.sol” not found: File import callback not supported
→ AccessControl.sol:5:1:
|
5 | import “…/utils/Context.sol”
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

5 | import “…/utils/Context.sol”

It’s because that path is incorrect. You need to have your pathing correct to files that exist otherwise it won’t see those files.