-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFaucet.sol
34 lines (25 loc) · 820 Bytes
/
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./SafeMath.sol";
contract Faucet {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IERC20 public token;
uint256 public immutable dripAmount;
constructor(address _token, uint256 _dripAmount) {
token = IERC20(_token);
dripAmount = _dripAmount;
}
function dripToken() external returns (bool, uint256) {
address user = msg.sender;
uint256 faucetBalance = token.balanceOf(address(this));
if(faucetBalance > dripAmount) {
token.safeTransfer(user, dripAmount);
return (true, dripAmount);
} else {
return (false, 0x0);
}
}
}