Created
December 8, 2021 09:10
-
-
Save aLIEzsss4/fa08a207de1d4ea85f96bbbdadca1da6 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.10+commit.fc410830.js&optimize=true&runs=200&gist=
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
// SPDX-License-Identifier: MIT | |
// hooks | |
pragma solidity >=0.7.0 <0.9.0; | |
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | |
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
import "@openzeppelin/contracts/utils/Strings.sol"; | |
contract ERC20Basic is ERC20, ERC20Burnable, Ownable { | |
uint256 public MintCount = 0; | |
mapping(address => Player) public players; | |
event Sent(address playerAddress, uint256 amount); | |
uint256 Intervals = 60; | |
struct Player { | |
address playerAddress; | |
uint256 amount; | |
uint256 latestTime; | |
} | |
modifier CurrentTimeCanResolve(address playerAddress) { | |
Player storage player = players[playerAddress]; | |
if (!(block.timestamp > player.latestTime + Intervals)) { | |
require( | |
block.timestamp > player.latestTime + Intervals, | |
Strings.toString( | |
Intervals - (block.timestamp - player.latestTime) | |
) | |
); | |
} | |
_; | |
} | |
constructor(string memory _name, string memory _symbol) | |
ERC20(_name, _symbol) | |
{} | |
function mint(address playerAddress, uint256 amount) | |
public | |
CurrentTimeCanResolve(playerAddress) | |
{ | |
uint256 OldAmount = players[msg.sender].amount; | |
players[msg.sender] = Player(playerAddress, amount, block.timestamp); | |
players[msg.sender].amount = players[msg.sender].amount + OldAmount; | |
MintCount += 1; | |
_mint(playerAddress, amount); | |
emit Sent(playerAddress, amount); | |
} | |
function hightLevelMint(address playerAddress, uint256 amount) | |
public | |
{ | |
uint256 OldAmount = players[msg.sender].amount; | |
players[msg.sender].amount = players[msg.sender].amount + OldAmount; | |
_mint(playerAddress, amount); | |
emit Sent(playerAddress, amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment