-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathErc777Token.sol
More file actions
65 lines (54 loc) · 2.09 KB
/
Erc777Token.sol
File metadata and controls
65 lines (54 loc) · 2.09 KB
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts-upgradeable/token/ERC777/ERC777Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
contract Erc777Token is ERC777Upgradeable, PausableUpgradeable, AccessControlUpgradeable {
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
uint private constant INITIAL_SUPPLY = 1000000000_000000000000000000;
string private constant TOKEN_NAME = "MyErc777";
string private constant TOKEN_SYMBOL = "ME777";
function initialize(
address[] memory defaultOperators
) public initializer {
__ERC777_init(TOKEN_NAME, TOKEN_SYMBOL, defaultOperators);
__Pausable_init();
__AccessControl_init();
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(PAUSER_ROLE, msg.sender);
_setupRole(MINTER_ROLE, msg.sender);
_mint(msg.sender, INITIAL_SUPPLY, "", "");
}
function pause() public onlyRole(PAUSER_ROLE) {
super._pause();
}
function unpause() public onlyRole(PAUSER_ROLE) {
super._unpause();
}
function mint(
address account,
uint256 amount,
bytes memory userData,
bytes memory operatorData
) public onlyRole(MINTER_ROLE) {
super._mint(account, amount, userData, operatorData, true);
}
function mint(
address account,
uint256 amount,
bytes memory userData,
bytes memory operatorData,
bool requireReceptionAck
) public onlyRole(MINTER_ROLE) {
super._mint(account, amount, userData, operatorData, requireReceptionAck);
}
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256 amount
) internal whenNotPaused override {
super._beforeTokenTransfer(operator, from, to, amount);
}
}