This is a guest post by Julian Khoo, VP Product Development and Co-Founder at Joget Inc. Julian leads the development of the open source Joget no-code/low-code application platform.
In this article, we will look at using a no-code approach to integrating blockchain technology, specifically an IBM Blockchain Platform network, into a full-fledged web application on the Joget application platform running on Red Hat OpenShift.
1.1 Blockchain and Digital Ledger Technology (DLT)
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.
1.2 Hyperledger Fabric and IBM Blockchain Platform
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.
IBM Blockchain Platform, on the other hand, is an enterprise-ready and managed full stack blockchain-as-a-service (BaaS) offering that is based on Hyperledger Fabric. IBM Blockchain Platform can be deployed on OpenShift or Kubernetes on a private, public or hybrid cloud environment.
1.3 Blockchain Concepts
If you are new to blockchain technology, there are quite a lot of 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.
- Blockchain ledger is a journal of all transactions and data that are stored in a distributed network.
- Peer nodes are the network components where copies of the blockchain ledger are hosted.
- Members are organizations that are part of the blockchain network.
- Certificate Authority (CA) issues certificates to identify users that belong to an organization.
- Membership Services Provider (MSP) maps certificates to member organizations.
- Transactions are requests to read or write data into the ledger.
- Ordering service are nodes that orders transactions into a block to be written into the ledger.
- Channels are private communication mechanisms to keep confidentiality between members in the network.
- Smart contracts (called chaincode in Fabric) are code within the blockchain network that are invoked to query or update the ledger.
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.
2. Overview of the App
Joget is an open source low-code/no-code application platform for faster, simpler digital transformation. To demonstrate the incorporation of blockchain technology in an app, let’s design a Joget app running on OpenShift that makes use of the Fabcar blockchain sample provided by IBM.
To demonstrate reading from and writing to the blockchain network, the app supports the following use cases:
- Query and list of all records from the blockchain network.
- Query and view a specific record from the blockchain network.
- Write a new record into the blockchain network after an approval process.
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 IBM Blockchain Platform network is then accomplished by simply configuring a set of Joget Hyperledger Fabric plugins.
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 on IBM Blockchain Platform, as well as to develop and configure the app.
3. Setup Hyperledger Fabric Network on IBM Blockchain Platform
To begin, let’s set up a Hyperledger Fabric Network on the IBM Blockchain Platform.
3.1 Deploy IBM Blockchain Platform on IBM Cloud
Follow the step-by-step guide to setting up a basic Hyperledger Fabric network. The steps are summarized below:
- Get an IBM Cloud Account and upgrade to "Pay-As-You-Go". With IBM Cloud, you are entitled to a free 30 day preview.
- Create the IBM Kubernetes Service
- Create the IBM Blockchain Platform Service
- Launch the IBM Blockchain Platform
- Add the certificate authority (CA)
- Register the users
- Create the organization’s Membership Service Provider (MSP) definition
- Create the peer node
- Create the orderer
- Add an organization as a consortium member on the orderer
- Create the channel
- Join the channel
3.2 Deploy Fabcar Blockchain Sample Smart Contract
Next, let’s deploy a sample smart contract on the network following the steps described in the Fabcar Blockchain Sample provided by IBM.
The summarized steps are:
- Clone the GitHub repository
- Package the smart contract
- Deploy FabCar Smart Contract on the network
- Download connection profile JSON
At this point, you should have a connection profile JSON to connect to the blockchain network.
4. Design Joget App
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.
If you do not already have a running Joget platform, follow the steps in Automating Low Code App Deployment on Red Hat OpenShift with the Joget Operator to set up the Joget environment which typically only takes minutes.
4.1 Design New 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.
- App ID: fabcar
- App Name: Hyperledger Fabric Fabcar Sample
4.2 Design Fabcar Form
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.
4.3 Use App Generator to Create App
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.
5. Configure Joget Hyperledger Fabric Plugins
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.
5.1 Upload Joget Hyperledger Fabric Plugins
NOTE: If you installed Joget on OpenShift using the Joget Operator, the default JBoss EAP application server configuration may limit file uploads to 10MB. To overcome this limitation, you can use the OpenShift CLI rsync command to directly upload the plugin file to the Joget pod:
cp joget-hyperledger-fabric.jar app_plugins/
oc rsync app_plugins pod_id:/home/jboss/wflow/
5.2 Configure List to Query Hyperledger Fabric Ledger
Switch to the Source tab, select the Hyperledger Fabric Datalist Binder then click on Next.
In the plugin configuration, key in the relevant configuration.
Hyperledger Fabric Configuration
|Membership Service Provider (MSP ID)||org1msp|
|User Enrollment||Register New User|
|Connection Profile JSON||Downloaded connection profile in JSON format|
|JSON Response Primary Key Property||Key|
|JSON Response Contains Nested Property||true|
|Base Nested Property Name||Record|
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.
5.3 Configure Form to View Hyperledger Fabric Ledger Record
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 Configuration values are similar to the configuration used for the datalist binder earlier.
|JSON Response Contains Nested Property||true|
|Base Nested Property Name||Record|
Note: #requestParam.id# is a request parameter hash variable to represent the id parameter in the URL.
Click on Save.
5.4 Configure Process to Update Hyperledger Fabric Ledger
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 Configuration 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.
6. What’s Next
This example serves to demonstrate how you can build a blockchain app on the Joget platform without coding. Download the app and plugin for this sample, and get started with IBM Blockchain Platform and Joget.
To learn more about the Joget platform:
- Visit the Joget product page
- Learn with the Getting Started Guide in the Knowledge Base.
- Learn via the Joget Academy.