Is it possible for a validator to get the current time without it being passed in via the redeemer? My validator is heavily dependent on the time being correct so it would probably be a bad design choice to allow the wallet to pass in the time, as it can lie about the current time.
The usual way to handle time in Plutus is using Slot ranges. This means that the script does not query the time. Instead it checks that the validation happens in a given slot interval that corresponds to a time. You can have a look at the notes about slots from the Plutus Pioneers Course.
With these slots, you can ensure that the validation takes place before, after or in a certain slot interval. And when you are sure that the validation takes place in a specific time interval, you also know the corresponding time. Each slot corresponds to one second as described here.
How about parameterizing the validator with
POSIXTime and passing the current time from the contract to the validator script using
That way, the wallet has no influence on it.
I could do this, but the issue is that the contract I am creating has quite a lot of different deadlines floating around. So asking for all of these up front would be annoying for someone using it and could allow for more mistakes/vulnerabilities. Oct 25, 2021 at 14:00