/
StableToken.sol
65 lines (55 loc) · 1.42 KB
/
StableToken.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
import "./utils/MetaContext.sol";
contract StableToken is ERC20Permit, MetaContext {
mapping(address => bool) public isMinter;
constructor(string memory name_, string memory symbol_) ERC20Permit(name_) ERC20(name_, symbol_) {}
function burnFrom(
address account,
uint256 amount
)
public
virtual
onlyMinter()
{
_burn(account, amount);
}
function mintFor(
address account,
uint256 amount
)
public
virtual
onlyMinter()
{
_mint(account, amount);
}
/**
* @dev Sets the status of minter.
*/
function setMinter(
address _address,
bool _status
)
public
onlyOwner()
{
isMinter[_address] = _status;
}
/**
* @dev Throws if called by any account that is not minter.
*/
modifier onlyMinter() {
require(isMinter[_msgSender()], "!Minter");
_;
}
// META-TX
function _msgSender() internal view override(Context, MetaContext) returns (address sender) {
return MetaContext._msgSender();
}
// Unreachable
function _msgData() internal view override(Context, MetaContext) returns (bytes calldata) {
return MetaContext._msgData();
}
}