Created
September 17, 2020 14:32
-
-
Save petejkim/31085e6df58d304b459d4e81a5178417 to your computer and use it in GitHub Desktop.
USDC Faucet in Goerli
This file contains hidden or 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 | |
// Copyright (c) 2020 petejkim | |
pragma solidity 0.6.12; | |
import { Ownable } from "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/access/Ownable.sol"; | |
import { IERC20 } from "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/token/ERC20/IERC20.sol"; | |
import { SafeERC20 } from "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.2.0/contracts/token/ERC20/SafeERC20.sol"; | |
contract USDCFaucet is Ownable { | |
using SafeERC20 for IERC20; | |
mapping (address => uint256) public lastClaimedAt; | |
uint256 public amount = 100000000; | |
uint256 public waitPeriod = 3600; | |
address public tokenAddress = 0x2f3A40A3db8a7e3D09B0adfEfbCe4f6F81927557; | |
function configure(uint256 newAmount, uint256 newWaitPeriod, address newTokenAddress) external onlyOwner { | |
amount = newAmount; | |
waitPeriod = newWaitPeriod; | |
tokenAddress = newTokenAddress; | |
} | |
function canClaim(address account) external view returns (bool) { | |
return lastClaimedAt[account] + waitPeriod < now; | |
} | |
function claim() external { | |
require(lastClaimedAt[msg.sender] + waitPeriod < now, "You cannot claim again so soon!"); | |
lastClaimedAt[msg.sender] = now; | |
IERC20(tokenAddress).safeTransfer(msg.sender, amount); | |
} | |
function drain() external onlyOwner { | |
IERC20 token = IERC20(tokenAddress); | |
token.safeTransfer(msg.sender, token.balanceOf(address(this))); | |
} | |
function destroy() external onlyOwner { | |
selfdestruct(msg.sender); | |
} | |
} |
0x7b63b475f60e848E2b2010a62c9c0cF5D6396Fcd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
EAmFfKHiYsHhavN9yQDtoGBs7YgXfi4sYwHYMuEgav6E