-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMetaToken.sol
More file actions
34 lines (25 loc) · 1.26 KB
/
MetaToken.sol
File metadata and controls
34 lines (25 loc) · 1.26 KB
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: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
contract MetaToken is ERC20, Ownable {
uint256 public constant MINT_AMOUNT = 10 * (10 ** 18); // 10 tokens (assuming 18 decimals)
uint256 public constant MINT_INTERVAL = 24 hours; // 24 hours interval
mapping(address => uint256) private lastMintTime;
constructor() ERC20("Meta", "META") Ownable(msg.sender) {
_mint(msg.sender, 1000 * (10 ** 18)); // Initial supply for the owner
}
function faucet() external {
require(block.timestamp >= lastMintTime[msg.sender] + MINT_INTERVAL, "Minting is allowed only once in 24 hours");
// Update last mint time
lastMintTime[msg.sender] = block.timestamp;
// Mint tokens to the user
_mint(msg.sender, MINT_AMOUNT);
}
function timeUntilNextMint(address account) external view returns (uint256) {
if (block.timestamp >= lastMintTime[account] + MINT_INTERVAL) {
return 0;
}
return (lastMintTime[account] + MINT_INTERVAL) - block.timestamp;
}
}