Blocks and time in Meadow?

When writing a smart contract with Meadow time is in blocks but how many blocks are in a day , hour, minutes,or seconds??

Good question. SL generates blocks every 20 seconds. The trouble is that some of these will be empty blocks. This is by design, to help the network synchronize. You won’t know which ones will be empty as these will pop up probabilistically on the chain.

To my best knowledge, because of the above, you can’t tie your conventional notion of time to an exact block. Empty blocks preclude you from executing if they appear at the time when you need to be running your code.

What you can do is code the contract to execute at block x with probability of execution of 99.99% at block x+t.

As long as variables don’t change between x and x+t, you should be fine, but for higher volatility stuff they really need to integrate some form of internal clock. I raised this issue a while ago.

They recently created Ouroboros chronos, which seems like a good solution for this problem.

1 Like