-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIvanmegacoin.sol
73 lines (61 loc) · 2.45 KB
/
Ivanmegacoin.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "@openzeppelin/contracts@4.3.3/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts@4.3.3/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts@4.3.3/token/ERC20/extensions/ERC20Snapshot.sol";
import "@openzeppelin/contracts@4.3.3/access/AccessControl.sol";
import "@openzeppelin/contracts@4.3.3/security/Pausable.sol";
import "@openzeppelin/contracts@4.3.3/token/ERC20/extensions/draft-ERC20Permit.sol";
import "@openzeppelin/contracts@4.3.3/token/ERC20/extensions/ERC20Votes.sol";
import "@openzeppelin/contracts@4.3.3/token/ERC20/extensions/ERC20FlashMint.sol";
/// @custom:security-contact toivan777@ya.ru
contract IvanMegacoin is ERC20, ERC20Burnable, ERC20Snapshot, AccessControl, Pausable, ERC20Permit, ERC20Votes, ERC20FlashMint {
bytes32 public constant SNAPSHOT_ROLE = keccak256("SNAPSHOT_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
constructor() ERC20("Ivan Megacoin", "IMGC") ERC20Permit("Ivan Megacoin") {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(SNAPSHOT_ROLE, msg.sender);
_setupRole(PAUSER_ROLE, msg.sender);
_mint(msg.sender, 100000000 * 10 ** decimals());
_setupRole(MINTER_ROLE, msg.sender);
}
function snapshot() public onlyRole(SNAPSHOT_ROLE) {
_snapshot();
}
function pause() public onlyRole(PAUSER_ROLE) {
_pause();
}
function unpause() public onlyRole(PAUSER_ROLE) {
_unpause();
}
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
_mint(to, amount);
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
whenNotPaused
override(ERC20, ERC20Snapshot)
{
super._beforeTokenTransfer(from, to, amount);
}
// The following functions are overrides required by Solidity.
function _afterTokenTransfer(address from, address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._afterTokenTransfer(from, to, amount);
}
function _mint(address to, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._mint(to, amount);
}
function _burn(address account, uint256 amount)
internal
override(ERC20, ERC20Votes)
{
super._burn(account, amount);
}
}