Created
September 17, 2022 07:42
-
-
Save jatubio/5c76bb489c4ae3cbd83610d1ac8369e9 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
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 | |
pragma solidity ^0.8.3; | |
//import Open Zepplins ERC-20 contract | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol"; | |
//create a sample token that inherits Open Zepplins ERC-20 contract | |
contract WATER is ERC20 { | |
uint public amountAllowed = 1000000000000000000; | |
//when deploying the token give it a name and symbol | |
//specify the amount of tokens minted for the owner | |
constructor() ERC20("WATER", "WATER") { | |
_mint(msg.sender, 50000000 * (10 ** 18)); | |
} | |
//when you requestTokens address and blocktime+1 hour is saved in Time Lock | |
mapping(address => uint) public lockTime; | |
//allow users to call the requestTokens function to mint tokens | |
function requestTokens (address requestor , uint amount) external { | |
//perform a few check to make sure function can execute | |
require(block.timestamp > lockTime[msg.sender], "lock time has not expired. Please try again later"); | |
//mint tokens | |
_mint(requestor, amount); | |
//updates locktime 1 hour from now | |
lockTime[msg.sender] = block.timestamp + 1 hours; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment