Generating Mobile Applications For Hyperledger Composer

Jake Turner
4 min readMay 21, 2018

--

Running the mobile application code generation tool

As part of my final year at university, I was required to complete a self-chosen project. I decided on undertaking a project which aimed to improve blockchain application development processes, particularly focusing on mobile applications.

My project resulted in a code generation tool which produces fully-functional mobile applications, that can interact with deployed Hyperledger Composer business networks.

Hyperledger Composer is an open-source toolset and development framework for rapidly accelerating blockchain application development. If you’re not already familiar with the Hyperledger Composer framework, then I suggest you check it out!

The code generation tool runs using the Yeoman scaffolding tool and generates mobile applications built with the Ionic Framework. Due to Ionic’s hybrid approach, mobile applications can run on both Android and iOS devices.

Running the code generation tool

First, the code generation tool needs to be installed using the following command:

npm install -g generator-composer-ionic

Next, the tool can be running using the command:

yo composer-ionic

When the code generation tool is run, it asks the user a series of questions regarding the mobile application that they wish to generate. The responses to these prompts are used in the code generation process, to produce a customised mobile application.

The code generation tool produces custom components for the mobile application by inspecting the provided Hyperledger Composer business network definition. This is either from supplying the code generation tool a business network archive file, or a business network card that connects to a deployed business network.

Specifically, these custom components are based on the Asset, Participant and Transaction data models inside the business network definition. This means that pages, forms and data are generated directly, using the business network definition. This save developers massive amounts of time, by reducing the amount of boilerplate code needed to get started with mobile application development.

Running a generated mobile application

The following mobile application was generated using Hyperledger Composers sample ‘car auction’ business network example.

When starting the generated mobile application, the user is presented with a basic home page and menu.

Mobile applications home page and menu

Selecting ‘Assets’ from the menu displays all of the asset types defined in the ‘car auction’ business network definition. Selecting the ‘Vehicle’ asset type causes the mobile application to get all of the ‘Vehicle’ instances from a running Hyperledger Composer REST API.

Selecting the ‘Vehicle’ asset type

Selecting the floating action button on the ‘Vehicle’ page opens a form for creating a new ‘Vehicle’ instance. The mobile applications forms are all generated automatically, using the business networks models.

Adding a new ‘Vehicle’ instance

Each instance of a ‘Vehicle’ asset can be viewed in detail to examine all of the properties and associated data.

Viewing a ‘Vehicle’ instance

Instances of the ‘Vehicle’ type can also be updated, to change any associated data.

Updating a ‘Vehicle’ instance

Each ‘Vehicle’ instance can also be logically deleted within the generated mobile application.

Deleting a ‘Vehicle’ instance

Participants are treated similarly to assets in generated mobile applications, as they can also be created, read, updated and deleted.

Displaying all ‘Member’ participant instances

Behaviour for transactions in generated mobile applications is different when compared to assets and participants. Transactions can only be read and created.

Viewing a submitted ‘Offer’ transaction

The mobile applications settings page allows users to change the REST API which is used for connecting to the running business network on the blockchain.

Future plans

There are plenty of features and work which will be implemented in later versions of tool, to improve the developer experience further.

Some of the more interesting planned features include:

  • Online version of the code generation tool — This allows users to generate mobile applications directly from a hosted web application without needing to install anything!
  • Multi-perspective mobile applications — At the moment, generated mobile applications are very generic. Instead, mobile applications can be generated for individual participant types, enabling participants to only view the actions and data relevant to them.
  • Authentication — Currently, REST API requests don’t require any authentication. Implementing authentication will force users to prove their identity before they’re able to interact with the business network.

At a future date when more testing and features are implemented, I will be making a request to integrate this mobile application code generation tool into the existing Hyperledger Composer toolset.

This project is still in development, so if you happen to find any problems or simply wish to contribute, then you can find the code and on GitHub.

For any inquiries or if you just want to get in touch, feel free to contact me on LinkedIn!

--

--