mirror of
git://holbrook.no/eth-faucet
synced 2025-01-09 02:27:32 +01:00
34 lines
754 B
Solidity
34 lines
754 B
Solidity
|
pragma solidity >0.8.0;
|
||
|
|
||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||
|
|
||
|
contract PeriodSimple {
|
||
|
|
||
|
address public owner;
|
||
|
address public poker;
|
||
|
uint256 public period;
|
||
|
mapping (address => uint256) public lastUsed;
|
||
|
|
||
|
event PeriodChange(uint256 _value);
|
||
|
|
||
|
constructor() {
|
||
|
owner = msg.sender;
|
||
|
poker = owner;
|
||
|
}
|
||
|
|
||
|
function setPeriod(uint256 _period) public {
|
||
|
require(owner == msg.sender, 'ERR_NOT_OWNER');
|
||
|
period = _period;
|
||
|
}
|
||
|
|
||
|
function check(address _subject) public view returns(bool) {
|
||
|
return block.timestamp < lastUsed[_subject] + period;
|
||
|
}
|
||
|
|
||
|
function poke(address _subject) public {
|
||
|
require(msg.sender == owner || msg.sender == poker, 'ERR_ACCESS');
|
||
|
require(check(_subject), 'ERR_PREMATURE');
|
||
|
lastUsed[_subject] = block.timestamp;
|
||
|
}
|
||
|
}
|