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:
-
too many licenses, solution: kept the top MIT license and removed all the other licenses, that worked
-
“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