Getting Started with Smart Contract Designer



When creating a new App, in order for you to create a Smart Contract, you will need to set up the type of the app to Hyperledger Fabric. 

Once the app is created you will navigate automatically to the Process Designer. From here you can easily access the App-based action: Smart Contract Designer   and start building your functions.


Building blocks that can be dragged and dropped onto the canvas


  • General Start: this is the first element that you drag and drop onto your canvas, when creating functions. It represents the Start of the function. You can add only one start.

                                                                                                                                                                                                                                            

  • General End: This element is an event that ends the Function. You can add only one.

                                                                                                                                     

  • Variable - Declare: The addition of a new variable used only inside the function.

                                                                                                                                      

  • Variable - Assign: This activity type node will allow you to assign values to previously declared variables. Note that the input and output variables are by default visible to any Assign activity.

                                                                                                                                    

  • Control - Expression: This activity type node it is more specific. This will allow you to add an entire chunk of a function by inserting custom code.

                                                                                                                                    

  • Control - If: This activity type is a conditional statements. They are used to perform different actions based on different conditions. In this case the if statement is used to evaluate that the condition to be executed is true. 


                                                                                                                                   

  • Looping - Do While: Manly this type of activity within a function will validate a specific part of a function only after executing that specific part of the function. 

                                                                                                                                   

  • Looping - While: As long as your condition is true the system will run everything that is between this While node and a delimitator (e.g. additional functions, conditions, nodes basically blocks of data) as being part of the said condition.

                                                                                                                                   

  • Looping - For: This type of loops are handy, if you want to run the same code over and over again, each time with a different value.


                                                                                                                                   

  • Control - Delimitator: This type of activity will ensure the function's flow logic. Meaning that it will delimit where the true or false branches of the if node end and also where all loops end.

                                                                                                                                    

Add Function

This is actually the first action you will need to do before adding activities on the canvas. You can add as many functions as per your business requirements. Bear in mind that each function will have its own activity elements.

Function DetailsFunction NameName displayed for the function
Function DetailsDescriptionUsed to describe business purpose for the function
Function DetailsIs PublicIt will allow the process & blockchain participants to access the function
Function DetailsIs not PublicAccessible only by another function within the Smart Contract
Function ParametersVariable NameThe name displayed for the input variable ( could be a,b or more complex salary, credit etc)
Function Input ParametersDescriptionUsed to describe business purpose for the input variable
Function Input ParametersIs Arrayif the checkbox is ticked then the system will identify the variable as a list used to describe business purpose for the input variable type
Function Input ParametersVariable TypeTypes of a variable (e.g. string, date/time, integer etc) or it can be from a defined data model - in this case the variable will receive the data model variable type
Return VariablesVariable nameThe name displayed for the return variable ( could be a,b or more complex salary, credit etc)
Return VariablesDescriptionUsed to describe business purpose for the return variable
Return VariablesIs Arrayif the checkbox is ticked then the system will identify the variable as a list used to describe business purpose for the return variable type
Return VariablesVariable TypeTypes of a variable (e.g. string, date/time, integer etc) or it can be from a defined data model - in this case the variable will receive the data model variable type



Function Actions

DeleteWill remove the function from the smart contract designer
EditBy using this action you will be able to edit the Details, Input and Return Parameters
PreviewBy clicking on this button, you will view your function written as code



Stage-based actions

These actions slightly differ based on what elements you have selected on your Canvas.

Append Variable

This will help you choose from a drop down list a variable ( this list will be populated with all the variables declared either at Function level - see Parameters - either on the declare node  )

Expression

Here you can create a logical schema ( e.g. the appended variable A = B+C, where B & C are previously declared variables)


Other buttons

Save - The system saves the work you’ve done in the Smart Contract Designer.

Add Declaration - On click the system will prompt you with the editable declaration details

Add Assignment  - On click the system will prompt you with the editable assignment details