Chennai Hyperledger Meetup — July had a good amount of people from various domains and industries. Our main focus on the event was a workshop on Hyperledger Composer. Most of the Blockchain meetups which is hosted in Chennai get good amount of participants who are new to Blockchain. So we wanted to concentrate on introducing the Tools and show a simple example on How to create Blockchain Applications with Hyperledger Composer & Wavemaker.

Before getting started I would like to thank Hyperledger for sending us awesome USBs. The USBs were given to all the participants in the Meetup.

Our main aim of the workshop was to do a commercial property leasing or house leasing application using Hyperledger Composer but we changed that to show an easier one so that it would be easier for new people to understand and start working. We picked the best and easiest one to develop and understand — Which was the Hyperledger Composer Marble Trade example. The reason for taking this example, many people wanting to learn Blockchain are finding it hard to understand the exact usecase on how to implement Blockchain on business networks. Marbles trade gives us good and simple steps to understand logic of how we transfer an asset between users on a business network using Blockchain. Also, we want to show how quickly you will be able to create a PoC with Hyperledger Composer and WaveMaker (Rapid Application Development for Web).

Before getting started everyone has to install Composer and start Fabric. The exact steps on composer installation and starting fabric are available on the Hyperledger Composer website — I would say this is the best place to get started. Anyway will post it here:

Prerequisites:

If you’re running on Ubuntu, you can download the prerequisites using the following commands:

Installing Hyperledger Composer development tools

1. The development tools you’ll need can all be installed with

 

2. To install composer-cli run the following command:

3. The composer-cli contains all the command line operations for developing business networks.

4. To install generator-hyperledger-composer run the following command:

5. The generator-hyperledger-composer is a Yeoman plugin that creates bespoke applications for your business network.

6. To install composer-rest-server run the following command:

7. The composer-rest-server uses the Hyperledger Composer LoopBack Connector to connect to a business network, extract the models and then present a page containing the REST APIs that have been generated for the model.

8. To install Yeoman run the following command:

9. Yeoman is a tool for generating applications. When combined with the generator-hyperledger-composer component, it can interpret business networks and generate applications based on them.

Optional development tools

1. If you use VSCode, install the Hyperledger Composer VSCode plugin from the VSCode marketplace.

2. If you want to run the Playground locally, install the composer-playground using the following command

Step 2: Starting Hyperledger Fabric

After the installation is successful you can start using Composer playground — playground is a tool to pre-test your Blockchain applications before deploying it. For this workshop we will not be testing with composer playground but we will directly create a Composer application and deploy it.

Step 1:
mkdir Marbles-Trade

cd Marbles-Trade && npm init

Step 2: 
mkdir lib 

mkdir models

Step 3:
cd models

vim marbles.cto

Step 4:

Hyperledger Composer includes a Logic file that is written in Javascript. The file contains the function to represent the Marble ownership trade between two players.

Step 5:

Hyperledger Composer includes an access control language (ACL) that provides declarative access control over the elements of the domain model. By defining ACL rules you can determine which users/roles are permitted to create, read, update or delete elements in a business network. Here we give allow access to all. Please Note: On this workshop we will not dig into Identity, we will talk more on that offline.

Step 6: Create & Deploy .bna

Package up your Business Network (lib/logic.js, models/marbles.cto, permission.acl & Package.json) and export it as an Archive called .bna file (or) Banana File. Which can be used to deploy on Fabric.

Once the .bna file is created without errors

Step 7: Start Composer Rest Server

Hyperledger Composer includes a standalone Node.js process that exposes a business network as a REST API. The LoopBack framework is used to generate APIs. This generates APIs for Assets, Participants and Transactions.

Once started open your browser to check http://localhost:3000/explorer

Now that the rest APIs are set, the next step is to create UIs for the Rest APIs. Composer comes with a Yo generator which generates an Angular Application. But this generates components for only Assets, we should separately do for Participants & Transactions. This is where WaveMaker comes in handy, one should know atleast the basics of Angular to work on the generated code. WaveMaker- Rapid Application Development tool is an easy to use tool for quick UI and logics. To use WaveMaker — the only skillset needed is basic Javascript.

For more information and tutorials on Hyperledger Composer check this

Step 3: Create UI for the Business Network using WaveMaker

Step 1: Create an free account with WaveMaker

Create a free account with WaveMaker – Getting Started

Step 2: Create a new App with WaveMaker & Select Web

Step 3: Select Template for your Web Application

For our simple usecase i will select Admin-Dashboard

Step 4: Adding REST APIs as services on Wavemaker

Select REST to add any service from our Generated APIs (In this example — we will add GET all Marbles API)

Step 5: Create a Variable to add the results to the Dashboard

Since the REST service gives us a JSON we will not be able to add the total number of values on the dashboard directly. So on success we will have to call Javascript component to get the Data Length.

Now lets run the application and see whether we are able to get the Total No of Marbles.

Likewise follow the same steps for getting the Total Number of Players.

Step 6: Include Form to Add Players and Marbles

Drag & Drop form component from Widgets, this will open the Configure Form dialog box

Add a player and check the dashboard for the count

Likewise try and add for Marbles.

Step 7: Do Transactions (Transfer ownership of Marble from one player to another)

Show all Marbles and Owners:

We select “M103” to be transferred to “test100@pramati.com”

Once the transaction successfully executes, open show all marbles again to see ownership change

This shows you a basic, easy and quick way to create an Admin dashboard or normal web applications for your Blockchain Business Network. One of the main reasons we have used WaveMaker is because it saves a lot of time in the Application front. We can spend more time on the Business network rather than Web Application.

An usecase to Collaborate on:

Though we have used Marbles Trade as an Example, our initial plan was to do a PoC on Commercial Property Leasing. We planned to do the same based on the Whitepaper written by ANZ & Westpac Australia. In coming weeks we will be hosting a community call where interested people can join in working on a PoC to understand and learn more on Hyperledger Fabric & Hyperledger Composer.

Finally thanks to Satheesh & DTCC for hosting the Meetup.

UseFull Links:

Hyperledger Foundation
Hyperledger Composer
Hyperledger Fabric
Composer Samples
Integrating with Node-RED
Hyperledger Composer & Node-RED
Test your Blockchain business network using Hyperledger Composer
Getting Started with Blockchain Development
Introduction to Hyperledger Composer
Jump start app essentials on WaveMaker
Leading the pack in Blockchain Banking
Blockchain rewires Financial Markets
Realizing the Potential of Blockchain
Distributed Ledger Technology and Bank Guarantees for Commercial Property Leasing