Joget is an open source low-code/no-code application platform for faster, simpler digital transformation. In this article, we will look at using a no-code approach to integrating blockchain technology, specifically a Hyperledger Fabric network, into a full-fledged web application.
In recent times there have been many predictions on blockchain technology revolutionizing the world, transforming everything from banking to supply chains and even government. Even if you are not familiar with the term, you would probably have heard of the rise of cryptocurrency like Bitcoin which utilizes blockchain technology. So what exactly is a blockchain?
To start, it’s best to understand a broader term called digital ledger technology (DLT). DLT is simply a decentralized database, where data is stored by a network of computers with no central authority. Blockchain is a specific type of DLT, where records in the network are linked using cryptography and cannot be changed. This lends itself to solving problems where there are issues with trust and inefficiencies due to centralized authorities.
There are many blockchain implementations, which are broadly categorized as either permissionless or permissioned. Permissionless blockchain networks are essentially public so anyone can participate, while permissioned ones are for restricted private use. Permissionless networks work well for public areas such as cryptocurrencies, but in an enterprise environment and in many industries, private networks are essential.
Enterprise blockchain networks might typically span across multiple organizations across an entire industry. With the need for permissioned private networks and participation by multiple organizations, how would a blockchain solution gain enough adoption to succeed? This is where Hyperledger comes in.
Hyperledger is a not a company, nor a specific product, but rather an umbrella of open source blockchain projects for enterprise use cases. Hosted by the Linux Foundation with more than 250 participating organizations, the projects are divided into frameworks and tools. Frameworks are different implementations of blockchain technology, each of which has different strengths for different use cases. Tools, on the other hand, are utilities to help manage or complement the frameworks.
The most popular and mature framework currently is Hyperledger Fabric. Originally contributed by IBM, Fabric is emerging as the de-facto standard for enterprise blockchain platforms, with commercial implementations and support from major vendors including IBM, Oracle and SAP.
If you are new to blockchain technology, there are quite of lot concepts to learn and understand. For the purpose of this sample app, here are some of the more important terms that are used to configure the blockchain integration.
The diagram provided by the Hyperledger Fabric project below shows how an application integrates with a blockchain network via smart contracts:
More details are available in the Hyperledger Fabric documentation.
To demonstrate the incorporation of blockchain technology in an app, let’s design a Joget app that makes use of the sample Fabcar network provided by Hyperledger Fabric. The Fabcar sample is basically a minimal stripped-down Fabric network for learning purposes.
To demonstrate reading from and writing to the blockchain network, the app supports the following use cases:
With Joget, the blockchain app can be developed without coding. A form is visually designed, after which the App Generator is used to quickly create a full working app. The integration to the Hyperledger Fabric blockchain network is then accomplished by simply configuring a set of Joget Hyperledger Fabric plugins.
To install and try out the final working app:
Here are some screenshots of the app in action:
Welcome: Home page
Fabcar Listing: List of all records from the blockchain network
Fabcar Form: View specific record from the blockchain network
Approval Process: Approve a creation of a new record
The next few sections provide more detailed information to setup the sample Hyperledger Fabric network, as well as to develop and configure the app.
To begin, install Hyperledger Fabric v1.3 and the Fabcar Network Sample.
The summarized installation steps below were tested on Ubuntu 18.04.
(https://hyperledger-fabric.readthedocs.io/en/release-1.3/prereqs.html)
Install cURL:
sudo apt install -y curl
Install Docker and Docker Compose (logout and login after the usermod command):
sudo apt install -y docker.iosudo apt install -y docker-composesudo usermod -aG docker $USER# logout and login after the usermod command
Install Go:
sudo apt install -y golang
Install NodeJS:
sudo apt install -y nodejssudo apt install -y npm
(https://hyperledger-fabric.readthedocs.io/en/release-1.3/install.html)
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/release-1.3/scripts/bootstrap.sh | bash -s 1.3.0
(https://hyperledger-fabric.readthedocs.io/en/release-1.3/write_first_app.html)
cd fabric-samples/fabcarnpm install./startFabric.shnode enrollAdmin.jsnode registerUser.jsnode query.js
Upon successful installation and execution of the last command, you should receive the query response from the blockchain network i.e.
Query has completed, checking results
Response is [{“Key”:”CAR0", “Record”:{“colour”:”blue”,”make”:”Toyota”,”model”:”Prius”,”owner”:”Tomoko”}},{“Key”:”CAR1", “Record”:{“colour”:”red”,”make”:”Ford”,”model”:”Mustang”,”owner”:”Brad”}},{“Key”:”CAR2", “Record”:{“colour”:”green”,”make”:”Hyundai”,”model”:”Tucson”,”owner”:”Jin Soo”}},{“Key”:”CAR3", “Record”:{“colour”:”yellow”,”make”:”Volkswagen”,”model”:”Passat”,”owner”:”Max”}},{“Key”:”CAR4", “Record”:{“colour”:”black”,”make”:”Tesla”,”model”:”S”,”owner”:”Adriana”}},{“Key”:”CAR5", “Record”:{“colour”:”purple”,”make”:”Peugeot”,”model”:”205",”owner”:”Michel”}},{“Key”:”CAR6", “Record”:{“colour”:”white”,”make”:”Chery”,”model”:”S22L”,”owner”:”Aarav”}},{“Key”:”CAR7", “Record”:{“colour”:”violet”,”make”:”Fiat”,”model”:”Punto”,”owner”:”Pari”}},{“Key”:”CAR8", “Record”:{“colour”:”indigo”,”make”:”Tata”,”model”:”Nano”,”owner”:”Valeria”}},{“Key”:”CAR9", “Record”:{“colour”:”brown”,”make”:”Holden”,”model”:”Barina”,”owner”:”Shotaro”}}]
Now that you have gotten the Fabcar network up and running, let’s start designing the Joget app that will query and update the records in the blockchain ledger. The Joget platform provides a modular dynamic plugin architecture to extend functionality. In this case, we will be using a set of Hyperledger Fabric plugins with Joget Enterprise Edition.
The first step is to design a new Joget app. In the Joget App Center, login as an administrator and click on the Design New App button. Key in the relevant details e.g.
Using the Joget Form Builder, design a form with fields matching the properties in a Fabcar record.
In this case create text fields with IDs that match a Fabcar record
Click on the Save button to save the form.
Once the form has been saved, click on the Generate App button to use the App Generator. Check the options for Generate Datalist, Generate CRUD and Generate Process — Approval Process, then Generate.
NOTE: The App Generator is a Joget Enterprise Edition feature, but you can manually create the list, process and UI in the Community Edition as well.
At this point, a full app to manage records, along with an approval process to create a new record has been created. These records are in the internal Joget database though, so now we will start configuring Hyperledger Fabric Plugins to directly integrate with the blockchain network.
Download the Hyperledger Fabric Plugins JAR file, and upload the downloaded jar file through Manage Plugins under System Settings.
In the app, enable the Quick Edit Mode so that you can view the editable elements. Browse to the Fabcar Listing and click on the quick edit link for the List to open the Datalist Builder.
Switch to the Source tab, select the Hyperledger Fabric Datalist Binder then click on Next. In the plugin configuration, key in the relevant details.
The values shown here are suitable for the default Fabcar sample network, but change the fabric_host to the correct hostname or IP in your environment:
If the configuration is correct, the Design tab will display the appropriate Fabcar columns to be used in the datalist. Add the columns to be displayed as required, then Save.
In the Fabcar Listing and click on View on a record. Click on the Fabcar Form quick edit link to open the Form Builder.
Switch to the Properties tab, select the Hyperledger Fabric Form Binder as the Load Binder then click on Next.
In the plugin configuration, key in the relevant details. The Hyperledger Fabric User and Channel values are similar to the configuration used for the datalist binder earlier.
Note: #requestParam.id# is a request parameter hash variable to represent the id parameter in the URL.
Click on Save.
In the Design App > Processes screen, click on Design Process to launch the Process Builder.
In the transition where the status is “Approved”, add a Tool called Invoke Fabric Transaction.
In the Map Tools to Plugins page, select the Hyperledger Fabric Tool for that Tool. In the plugin configuration, key in the relevant details. The Hyperledger Fabric User and Channel values are similar to the configuration used for the datalist binder earlier.
Note: #form.fabcar.field# is a form hash variable that represents the form field value.
This example serves to demonstrate the simplicity of building a blockchain app using the Joget platform without coding.
Download the app and plugin for this sample, and get started with Hyperledger Fabric and Joget.
To get started on the digital transformation journey with Joget: