State Machine

Blockchain development can be model as a State Machine.

The set of all the functions deployed on chain is the State token_transfer Function (STF) of a State Machine.

The State Machine comes with the basic concepts, an Input is applied to the Current State, under the rule of State token_transfer Function to transit the Current State into a New State.

State Machine

Here is an example, let's assume we have a Current State of block number 100:

While in the block 100, Bob is sending a transaction to move USDC balance from Bob to Alice:

The token_transfer function is accepting the transaction as the Input of State Machine, outputs a New State:

As an example, we can take a look how the token_transfer STF is written in python:

This is a very basic function, we use get and put API calls here. For the security reason, we should do more check for the arguments.

Last updated