Chapter 3: Advanced

Lesson 11: Block Number

When we are working on a contract, we may feel the need to verify the sequence in which certain events occur.

As we are dealing with a blockchain, we can leverage the block number at the time of execution of any transition to help us achieve this. A neat trick is to treat this notion like the passage of time.

For example, we can declare a mutable field last_invocation in our contract.

When the throttled_operation transition is called, we check if the current Block Number is sufficiently larger than that of the last invocation.