-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeToken.sol
44 lines (34 loc) · 1.22 KB
/
timeToken.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.13;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract timedToken is ERC20("TIME TOKEN","TT") {
mapping(address => uint) public lastSpent;
mapping(address => uint) public alreadySpent;
mapping(address => bool) public exclusions;
uint public limitPerDay = 5;
function timedTransfer(address to, uint amount) public {
if(exclusions[msg.sender] == false){
if(block.timestamp - lastSpent[msg.sender] > 1 minutes){
lastSpent[msg.sender] = block.timestamp;
alreadySpent[msg.sender] = amount;
_transfer(msg.sender, to, amount);
}else{
if((alreadySpent[msg.sender] + amount) > limitPerDay){
revert("limit exceeded");
}else{
lastSpent[msg.sender] = block.timestamp;
alreadySpent[msg.sender] += amount;
_transfer(msg.sender, to, amount);
}
}
}else{
_transfer(msg.sender, to, amount);
}
}
function mint() public{
_mint(msg.sender,5);
}
function addToExclusion(address exclude) public{
exclusions[exclude] = !exclusions[exclude];
}
}