Created
February 15, 2022 04:14
-
-
Save jchudzynski/ddbda93251010c7c6d1e622560c6c274 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
// Author: Janusz Chudzynski | |
pragma solidity >=0.4.22 <0.9.0; | |
contract Faucet { | |
mapping(address=>uint) lastTransfers; | |
uint amountToWithdraw = 10 ** 18 * 0.01; | |
function requestTokens(address payable requestor) external { | |
uint lastTransfer = lastTransfers[requestor]; | |
require(lastTransfer + 1 hours <= block.timestamp, "Patience is a virtue. You already requested funds hour ago"); | |
require(address(this).balance >= amountToWithdraw, "Not enough funds in the faucet. Please donate"); | |
requestor.transfer(amountToWithdraw); | |
lastTransfers[requestor] = block.timestamp; | |
} | |
function getBalance() public view returns (uint) { | |
return address(this).balance; | |
} | |
receive() external payable {} | |
fallback() external payable {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment