Hi, I tried to create a ERC20 token using the wizard here https://docs.openzeppelin.com/contracts/4.x/wizard
For features, I checked (Burnable, Pausable, Snapshots, Permit), for access control I checked (Roles)
Then after opening in Remix & Compiling, the code does not verify on Etherscan.io,
here is the code // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
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";
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", "MYTOKEN") 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);
}
}
Skyge
2
I think you should verify your code manually, and I think this tutorial can help you:
Verify smart contract inheriting from OpenZeppelin Contracts
i did uplode in multi-file format that also gives me error
here is the error
ParserError: Source "IERC20.sol" not found: File import callback not supported
--> ERC20.sol:5:1:
|
5 | import "./IERC20.sol"
| ^^^^^^^^^^^^^^^^^^^^^^
ParserError: Source "extensions/IERC20Metadata.sol" not found: File import callback not supported
--> ERC20.sol:6:1:
|
6 | import "./extensions/IERC20Metadata.sol"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ParserError: Source "utils/Context.sol" not found: File import callback not supported
--> ERC20.sol:7:1:
|
7 | import "../../utils/Context.sol"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ParserError: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File import callback not supported
--> token.sol:4:1:
|
4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ParserError: Source "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol" not found: File import callback not supported
--> token.sol:5:1:
|
5 | import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ParserError: Source "@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol" not found: File import callback not supported
--> token.sol:6:1:
|
6 | import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Snapshot.sol"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ParserError: Source "@openzeppelin/contracts/access/AccessControl.sol" not found: File import callback not supported
--> token.sol:7:1:
|
7 | import "@openzeppelin/contracts/access/AccessControl.sol"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ParserError: Source "@openzeppelin/contracts/security/Pausable.sol" not found: File import callback not supported
--> token.sol:8:1:
|
8 | import "@openzeppelin/contracts/security/Pausable.sol"
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ParserError: Source "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol" not found: File import callback not supported
--> token.sol:9:1:
|
9 | import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol"
Skyge
5
It looks like you do not install dependency, try to run:
npm i @openzeppelin/contracts
i am using remix. its works fine in local enviroment