Created
February 14, 2022 04:35
-
-
Save jchudzynski/766e8b4d5cda8fe1a3a56599037dbd46 to your computer and use it in GitHub Desktop.
Faucet
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 maxAllowed = 10 ** 18 * 5000; | |
constructor() { | |
} | |
function requestTokens(address payable requestor, uint amount) external { | |
uint lastTransfer = lastTransfers[requestor]; | |
require(lastTransfer > block.timestamp + 1 hours, "You already requested funds hour ago"); | |
require(address(this).balance > maxAllowed, "Not enough funds in the faucet. Please donate"); | |
require(maxAllowed - amount >= 0, "Requested More than allowed"); | |
requestor.transfer(amount); | |
lastTransfers[requestor] = amount; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment