-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathN2DRewards-MaxSupply-ERC20-Contract.sol
79 lines (63 loc) · 3.04 KB
/
N2DRewards-MaxSupply-ERC20-Contract.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
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-License-Identifier: MIT LICENSE
/*
Follow/Subscribe Youtube, Github, IM, Tiktok
for more amazing content!!
@Net2Dev
███╗░░██╗███████╗████████╗██████╗░██████╗░███████╗██╗░░░██╗
████╗░██║██╔════╝╚══██╔══╝╚════██╗██╔══██╗██╔════╝██║░░░██║
██╔██╗██║█████╗░░░░░██║░░░░░███╔═╝██║░░██║█████╗░░╚██╗░██╔╝
██║╚████║██╔══╝░░░░░██║░░░██╔══╝░░██║░░██║██╔══╝░░░╚████╔╝░
██║░╚███║███████╗░░░██║░░░███████╗██████╔╝███████╗░░╚██╔╝░░
╚═╝░░╚══╝╚══════╝░░░╚═╝░░░╚══════╝╚═════╝░╚══════╝░░░╚═╝░░░
THIS CONTRACT IS AVAILABLE FOR EDUCATIONAL
PURPOSES ONLY. YOU ARE SOLELY REPONSIBLE
FOR ITS USE. I AM NOT RESPONSIBLE FOR ANY
OTHER USE. THIS IS TRAINING/EDUCATIONAL
MATERIAL. ONLY USE IT IF YOU AGREE TO THE
TERMS SPECIFIED ABOVE.
*/
pragma solidity 0.8.4;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract N2DRewards is ERC20, ERC20Burnable, Ownable {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => bool) controllers;
uint256 private _totalSupply;
uint256 private MAXSUP;
uint256 constant MAXIMUMSUPPLY=1000000*10**18;
constructor() ERC20("N2DRewards", "N2DR") {
_mint(msg.sender, 1000000 * 10 ** 18);
}
function mint(address to, uint256 amount) external {
require(controllers[msg.sender], "Only controllers can mint");
require((MAXSUP+amount)<=MAXIMUMSUPPLY,"Maximum supply has been reached");
_totalSupply = _totalSupply.add(amount);
MAXSUP=MAXSUP.add(amount);
_balances[to] = _balances[to].add(amount);
_mint(to, amount);
}
function burnFrom(address account, uint256 amount) public override {
if (controllers[msg.sender]) {
_burn(account, amount);
}
else {
super.burnFrom(account, amount);
}
}
function addController(address controller) external onlyOwner {
controllers[controller] = true;
}
function removeController(address controller) external onlyOwner {
controllers[controller] = false;
}
function totalSupply() public override view returns (uint256) {
return _totalSupply;
}
function maxSupply() public pure returns (uint256) {
return MAXIMUMSUPPLY;
}
}