-
Notifications
You must be signed in to change notification settings - Fork 1
/
RewardToken.sol
35 lines (28 loc) · 1.02 KB
/
RewardToken.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
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "solady/src/auth/OwnableRoles.sol";
/**
* @title A simple reward token with OwnableRoles
* @dev only an address with 'minterRole' can mint
*/
contract RewardToken is ERC20, OwnableRoles {
uint256 constant minterRole = _ROLE_0;
uint256 constant INITIAL_OWNER_BALANCE = 100 ether;
constructor () ERC20("RewardToken", "RWT") {
_initializeOwner(msg.sender);
_mint(msg.sender, INITIAL_OWNER_BALANCE);
}
function setMinter(address _newMinter) external onlyOwner {
_grantRoles(_newMinter, minterRole);
}
function removeMinter(address _oldMinter) external onlyOwner {
_removeRoles(_oldMinter, minterRole);
}
function mint(address account, uint256 amount) external onlyRoles(minterRole) {
_mint(account, amount);
}
function burn(uint256 amount) external {
_burn(msg.sender, amount);
}
}