-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11-Minimal Token.sol
44 lines (38 loc) · 1.1 KB
/
11-Minimal Token.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract UnburnableToken {
mapping(address => uint) public balances;
uint public totalSupply;
uint public totalClaimed;
mapping(address => bool) private isClaimed;
error TokensClaimed();
error AllTokensClaimed();
error UnsafeTransfer(address to);
constructor() {
totalSupply = 100_000_000;
}
function claim() public {
if (totalClaimed >= totalSupply) {
revert AllTokensClaimed();
}
if (isClaimed[msg.sender]) {
revert TokensClaimed();
}
balances[msg.sender] += 1000;
totalClaimed += 1000;
isClaimed[msg.sender] = true;
}
function safeTransfer(address _to, uint _amount) public {
if (address(_to).balance == 0) {
revert UnsafeTransfer(_to);
}
if (_to == address(0)) {
revert UnsafeTransfer(_to);
}
if (balances[msg.sender] < _amount) {
revert UnsafeTransfer(_to);
}
balances[msg.sender] -= _amount;
balances[_to] += _amount;
}
}