-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEssentialToken.sol
59 lines (49 loc) · 1.69 KB
/
EssentialToken.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "./core/ERC20.sol";
import "./core/utils/BlackList.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract EssentialToken is Initializable, ERC20, Pausable, Ownable, BlackList {
constructor() {
_disableInitializers();
}
function initialize(
address _owner,
string memory _name,
string memory _symbol,
uint8 _decimals,
uint256 _initialSupply,
uint256 _maxSupply
) external initializer {
_transferOwnership(_owner);
ERC20.init(
_name,
_symbol,
_decimals,
_maxSupply == type(uint256).max ? type(uint256).max : _maxSupply * 10 ** _decimals
);
_mint(_owner, _initialSupply * 10 ** _decimals);
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
function blockAccount(address _account) public onlyOwner {
_blockAccount(_account);
}
function unblockAccount(address _account) public onlyOwner {
_unblockAccount(_account);
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override whenNotPaused {
require(!isAccountBlocked(to), "BlackList: Recipient account is blocked");
require(!isAccountBlocked(from), "BlackList: Sender account is blocked");
super._beforeTokenTransfer(from, to, amount);
}
}