-
Notifications
You must be signed in to change notification settings - Fork 1
/
ETD_faucet.sol
39 lines (31 loc) · 1.12 KB
/
ETD_faucet.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
pragma solidity ^0.5.1;
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
contract Fauct{
uint constant public tokenAmount = 1000000000000000000;
//单笔限制 1 ETD
uint constant public waitTime = 30 minutes;
//代币领取冷却30min
IERC20 public tokenInstance;
mapping (address => uint) LastAcessTime;
constructor(address _tokenInstance) public {
require(address(_tokenInstance) != address(0));
tokenInstance = IERC20(_tokenInstance);
}
function requestAmount() public {
require(AllowToWithdraw(msg.sender),"request Token within 30 minutes");
tokenInstance.transfer(msg.sender,tokenAmount);
LastAcessTime[msg.sender] = block.timestamp + waitTime;
}
function AllowToWithdraw(address _address) view public returns (bool) {
if (LastAcessTime[_address] == 0){
return true;
}
else if (LastAcessTime[_address] <= block.timestamp){
return true;
}
return false;
}
}