Created
August 1, 2022 17:58
-
-
Save casweeney/c8451dae53ef20b724b943b6d85e29c8 to your computer and use it in GitHub Desktop.
Jesserc Implementation
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.7; | |
contract Counter{ | |
uint public count; | |
uint timer = 0; | |
error timeNotReached(string); | |
bool reached = false; | |
modifier requiredTime(){ | |
if(block.timestamp < timer){ | |
revert timeNotReached("Sorry wait till 30 seconds"); | |
} | |
_; | |
} | |
function increment() public requiredTime { | |
updateTime(block.timestamp + 30 seconds); | |
count++; | |
} | |
function decrement() requiredTime public{ | |
count--; | |
updateTime(block.timestamp + 30 seconds); | |
} | |
function updateTime(uint _timer) internal{ | |
timer = _timer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment