I'm running a tool to audit my smart contract and I got as report the following:
uses timestamp for comparisons / Dangerous comparisons :
require(block.timestamp > nextPayment, "Payement not due yet");
I've done more research and I found that block.timestamp can be manipulated by miners which is why is better to use other methods for comparison than block.timestamp
Do you have any method safer than this one ?
Nb: block.timestamp defines the Now in solidity
Best Answer
The 15-second Rule states that if your contract's code does not rely on a time interval of less then 15 seconds, than it is probably safe to use
block.timestamp
.I understand that your smart contract is about recurring payments, so unless these payments' time interval is less than 15 seconds, your code is safe.
You can read more about Timestamp Dependence here.
All the best!