-
Notifications
You must be signed in to change notification settings - Fork 0
/
BRAIN20.sol
67 lines (44 loc) · 1.7 KB
/
BRAIN20.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
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
import './BEP20.sol';
import './SafeMath.sol';
import './Authorization.sol';
contract BRAINS20 is BEP20, Authorization {
using SafeMath for uint256;
constructor() BEP20("TOKEN EXAMPLE", "TOKEKENX", 18) {
_initRole(DEFAULT_ADMIN_ROLE, msg.sender);
_initRole(PAUSER_ROLE, msg.sender);
_initRole(MINTER_ROLE, msg.sender);
_initRole(BURNER_ROLE, msg.sender);
}
function pause() public onlyOwner {
require(hasRole(PAUSER_ROLE, msg.sender));
_pause();
}
function unpause() public onlyOwner {
require(hasRole(PAUSER_ROLE, msg.sender));
_unpause();
}
function mint(uint256 amount) public {
require(hasRole(MINTER_ROLE, msg.sender));
_mint(_msgSender(), amount);
}
function mintTo(address account, uint256 amount) public {
require(hasRole(MINTER_ROLE, msg.sender));
_mint(account, amount);
}
function burn(uint256 amount) public returns (bool) {
require(hasRole(BURNER_ROLE, msg.sender));
_burn(_msgSender(), amount);
return true;
}
function burnFrom(address account, uint256 amount) public {
require(hasRole(BURNER_ROLE, msg.sender));
uint256 currentAllowance = allowance(account, _msgSender());
_approve(account, _msgSender(), currentAllowance.sub(amount, "BEP20: burn amount exceeds balance"));
_burn(account, amount);
}
function _beforeTokenAction(address from, address to, uint256 amount) internal whenNotPaused override {
super._beforeTokenAction(from, to, amount);
}
}