Control Flow
In every application, we have a way in which logic can be designed. In this sense, ASC Builder can be used to create a logical expression such as an If
statement which uses comparative operators and performs actions when due according to conditions met or not met.
The structure is thus:
Decision Node
├── Met Node
│ ├── Condition Node
│ ├── Routine Node
│ │ ├── Action Node
├── Routine Node
│ ├── Action Node
A typical illustration of a decision statement would be to create two variables such as txn_sender and creator_address thus:
We may want to check if the transaction sender is the creator of the smart contract and approve if that is the case or reject if that is not the case.
To do this, we follow these steps:
Create a Decision node
Create a Met node and add it to the Decision node.
Create a Routine node and add it to the Decision node.
Add a Condition node to the Met node, which has the first operand as
txn_sender
, second operand ascreator_address
and the operator asIs Equal to
.Add a Routine to the Met node.
Add an Action to the just added Routine with
Approve Transaction
.Add an Action node to the Routine directly nested in the Decision node with
Reject Transaction
.
The resulting GUI would appear thus:
The structure of a decision MUST follow the following pattern.
You can watch the video in this Tweet to see how this is done.