A state machine defines a global state and transitions from one state to another.
Archetype provides the possibility to design the contract as a state machine; it simplifies the management of the contract's state compared to a manual management with
nat variables, because the only way to change the contract state is through transition entrypoints, which puts the contract's state under explicit control.
states keyword is used to declare the contract's states.
See the states article for more information.
A transition is an entrypoint that changes the contract states. It provides a dedicated syntax to define guard conditions and transition effect.
For example, the following entrypoint
See the transition article for more information.
state is section allows the execution of an entrypoint (ie does not fail) only when the contract is in the specified state.
For example, the following entrypoint fails if the current contract state is not
See the Sections article for more information on sections.
It is possible to interrogate the contract state anywhere in any entrypoint effect with the
state constant. It is not possible to assign a value with an assignment instruction. Use a transition to change contract's state.