This repository has been archived by the owner on Jan 17, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
71 additions
and
213 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { task } from "@nomiclabs/buidler/config"; | ||
import { defaultNetwork } from "../../../buidler.config"; | ||
|
||
export default task( | ||
"get-tokenFaucet", | ||
`Return (or --log) <erc20address> allowance by <owner> to <spender> on [--network] (default: ${defaultNetwork})` | ||
) | ||
.addPositionalParam( | ||
"address", | ||
"address of desired token to receive 50 from the faucet" | ||
) | ||
.addFlag("log", "Logs return values to stdout") | ||
.setAction(async (taskArgs) => { | ||
const myUserWallet = await getUserWallet(); | ||
const myUserAddress = await myUserWallet.getAddress(); | ||
const tokenFaucetAbi = ["function mint(address _token)"]; | ||
|
||
const tokenFaucet = await ethers.getContractAt( | ||
network.config.deployments.GelatoTokenFaucet | ||
); | ||
const tx = await tokenFaucet.mint(taskArgs.address); | ||
console.log(`\n Tx hash: ${tx.hash}\n`); | ||
await tx.wait(); | ||
console.log( | ||
`\n Successfully transferred 50 tokens of token ${taskArgs.address} tokenFaucet to your User account: ${myUserAddress}\n` | ||
); | ||
return tx.hash; | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// "SPDX-License-Identifier: UNLICENSED" | ||
pragma solidity ^0.6.10; | ||
|
||
import {SafeERC20} from "@gelatonetwork/core/contracts/external/SafeERC20.sol"; | ||
import {IERC20} from "@gelatonetwork/core/contracts/external/IERC20.sol"; | ||
|
||
interface IDecimalERC20 { | ||
function decimals() external view returns(uint8); | ||
} | ||
|
||
contract GelatoTokenFaucet { | ||
|
||
mapping(address => uint256) lastMintingTime; | ||
using SafeERC20 for IERC20; | ||
|
||
|
||
function mint(address _token) public { | ||
// Users can only mint once per day | ||
require(lastMintingTime[msg.sender] < block.timestamp - 24 hours, "Daily allowance depleted"); | ||
|
||
IERC20 token = IERC20(_token); | ||
uint256 mintAmount = 50 * 10 ** uint256(IDecimalERC20(_token).decimals()); | ||
|
||
// Faucet requires sufficient balance | ||
require(token.balanceOf(address(this)) > mintAmount, "Faucet is depleted"); | ||
|
||
// Effect | ||
lastMintingTime[msg.sender] = block.timestamp; | ||
|
||
// Transfer 50 tokens to user | ||
token.transfer(msg.sender, mintAmount); | ||
|
||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
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
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
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