I have written a smart contract which gets the block.timestamp and limits the caller to call the contract until the 2 hours passed as following:
mapping(address => uint256) public coffeKitchenLatestAqcuiredBalances;
function requestStarCoinFromCoffeeKitchenFaucet() public {
address callerAddress = msg.sender;
uint256 userLastRetrieveTime = coffeKitchenLatestAqcuiredBalances[callerAddress];
if (userLastRetrieveTime != 0){
uint256 epochNow = block.timestamp;
require(userLastRetrieveTime < epochNow - 7200,"You need to wait for 2 hours from your last call");
}
}
However I did not manage to extract to timestamp to limit the call time should be from 8AM to 6PM.
How can I format the epoch timestamp and check it on the smart contract call?