-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbase4
More file actions
30 lines (25 loc) · 774 Bytes
/
base4
File metadata and controls
30 lines (25 loc) · 774 Bytes
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract TimedCounter {
uint public count;
uint public lastUpdated;
uint public cooldown;
constructor(uint _initial, uint _cooldown) {
count = _initial;
cooldown = _cooldown; // örn: 10 saniye
lastUpdated = block.timestamp;
}
function increment() public {
require(block.timestamp >= lastUpdated + cooldown, "Please wait before next increment");
count += 1;
lastUpdated = block.timestamp;
}
function decrement() public {
require(count > 0, "Cannot go below zero");
count -= 1;
lastUpdated = block.timestamp;
}
function setCooldown(uint _newCooldown) public {
cooldown = _newCooldown;
}
}