forked from neptune-mutual-blue/protocol
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFakeToken.sol
49 lines (40 loc) · 1.21 KB
/
FakeToken.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
// Neptune Mutual Protocol (https://neptunemutual.com)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
contract FakeToken is ERC20 {
address public immutable deployer;
mapping(address => bool) public minters;
uint8 private immutable _decimals;
function addMinter(address account, bool flag) public onlyDeployer {
minters[account] = flag;
}
modifier onlyDeployer() {
require(msg.sender == deployer, "Forbidden");
_;
}
constructor(
string memory name,
string memory symbol,
uint256 supply,
uint8 decimalPlaces
) ERC20(name, symbol) {
require(decimalPlaces > 0, "Invalid decimal places value");
super._mint(msg.sender, supply);
deployer = msg.sender;
minters[msg.sender] = true;
_decimals = decimalPlaces;
}
function decimals() public view virtual override returns (uint8) {
return _decimals;
}
function mint(uint256 amount) external {
if (amount > 2000 * (10**_decimals)) {
require(minters[msg.sender], "Please specify a smaller value");
}
super._mint(msg.sender, amount);
}
function burn(uint256 amount) external {
super._burn(msg.sender, amount);
}
}