Blockchain Business Networks in Hyperledger Composer


Blockchain Business Networks in Hyperledger Composer

Recipe ID: hsts-r14


Self-paced training

We offer blockchain introduction, Hyperledger for system admin, Ethereum, Solidity, Corda R3, Hyperledger for developers, blockchain cybersecurity and more classes in self-paced video format starting at $60. Click here to learn more and register. For complete self-paced blockchain training, visit our Complete Blockchain Development Training page.


Recipe Overview

Hyperledger Composer is a set of collaboration tools for business owners and developers that make it easy to write chaincode for Hyperledger Fabric and decentralized applications (DApps). With Composer, you can quickly build POC and deploy chaincode to the blockchain in a short amount of time. Hyperledger Composer consists of the following toolsets:

In this recipe, we will explore the Composer business network and development components, including implementing models, transaction logic, access control, and query definitions. We will set up a development environment, and cover the use of the Hyperledger Playground for testing.

For those who are not familiar with Hyperledger project, reading Blockchain Overview, Intro to Hyperledger Family and Hyperledger Blockchain Ecosystem, Hyperledger Design Philosophy and Framework Architecture, Overview of Building Blockchain Smart Contracts in Hyperledger and The Survey of Hyperledger Fabric Architecture and Components for Blockchain Developers articles are strongly recommended beforehand.

In this recipe, we will cover the Hyperledger Composer business network and development components followed by Setting up the Hyperledger Composer Prerequisites & Development environment and Configuring a Hyperledger Composer business network recipes. After completing 3 mentioned recipes, it’s recommended to learn the following topics: i- Implementing models, transaction logic, access control, and query definitions, ii- Deploying, testing, and exporting business network archives using the Composer command-line interface and iii- Interacting with Composer through the RESTful API.

The Hyperledger Composer Business Network and Development Components
You can use Hyperledger Composer to quickly build a business network. Here, you can define assets, participants, transactions, access-control rules, and optional events and queries in the business network. A model (.cto) file contains all of the preceding definitions in the business network. Asset is an associate with a real-world object, and participants have their own unique identity. The transactions will interact with assets.
Participants can do this via transactions. The structure of a business network also includes an access control (permissions.acl), which specifies the access-control rules, a script (logic.js) file that implements transaction logic, and a package.json file that contains project metadata:

Pharmaceutical Supply Chain Business Network

In this recipe, we will develop an application called FarmaTrace Enterprise (FTE), which will use the Hyperledger Composer tool. FTE will enable end-to-end tracking of medicinal products throughout the pharmaceutical supply chain. There are a variety of challenges that the pharmaceutical supply chain and its stakeholders face daily. The process is time-consuming and information about it is not efficient and transparent to all parties. Creating a flexible and holistic supply chain strategy can allow companies to have better control over processes, enhance communication, and reduce costs:

We aim to provide a general design and implementation approach for Composer applications. This commonly-used procedure will help you to understand how to quickly start. In the FarmaTrace application, we will build a business network and components. Here, we show how a typical pharmaceutical supply chain works. However, it could be much more complex in a real-world use case. The following is how the FarmaTrace process flow works.


Pharmaceutical Supply Chain Process flow

First, we need to understand the entire process flow:

The manufacturer produces drugs, then packages and labels them

The distribution company gathers packaged products and begins delivery

The distribution company sends drugs to pharmacies

The distribution company sends drugs to hospitals

The distribution company sends drugs to physicians

Customers buy drugs from a pharmacy, hospital, or physician

Process flow can be illustrated as below:

Pharmaceutical Supply Chain Entities

Next, we need to identify entities for a FarmaTrace application; participants are categorized into six entities:

Pharmaceutical Supply Chain Assets

We will record every transaction in the blockchain; information for these records is stored in a receipt asset object. All participants in the network can trace this receipt. The drug receipt will have all process evidence information for each transaction. This can be used to provide proof for certain steps, which need to display required documents. The asset also defines certain rules that only allow authorized parties to perform permitted transaction actions. The receipt will contain other asset information, such as the drug status, to trace the transaction proof in each step.

Pharmaceutical Supply Chain Query

Now we will check which parameters are needed to allow us to search for drug information:

 

We have analyzed the FarmaTrace application business use case and development components. To build a business network, we will create all of the following critical files:

We will create these files after we set up a development environment in the Configuring a Composer business networkrecipe.

Putting Things Together

Designing network topology is a critical step for an enterprise blockchain. For our FarmaTrace application, the deployed Composer business network will look like the following:

All six participants are attending the network and can communicate with each other. The methods written in farmatrace-logic.js will be converted into Fabric chaincode. By invoking chaincode, the Fabric order service will provide a shared communication channel and broadcast transactions to peers. Peers will verify the transactions and commit and apply the same sequence of transactions. Eventually peers will update their state in the same way.

Congratulation! We have successfully learned how to create a business network on Hyperledger Composer. The next step is Set up the Hyperledger Composer Prerequisites & Development environment and Configuring a Hyperledger Composer business network.

The following recipes are excellent resources for installing other Hyperledger tools:
Blockchain Developer Guide- How to Install Hyperledger Fabric on AWS
Blockchain Developer Guide- How to Install and work with Hyperledger Sawtooth
Blockchain Developer Guide- How to Install Hyperledger Burrow on AWS
Blockchain Developer Guide- How to Install Hyperledger Iroha on AWS
Blockchain Developer Guide- How to Install Hyperledger Indy and Indy CLI on AWS
Blockchain Developer Guide- How to Install Hyperledger Seth and Docker on AWS

To conclude this recipe, we like to recommend our Blockchain Hyperledger Development in 30 hours course to those interested in pursuing a blockchain development career. Indeed, as of this writing, Hyperledger Foundation offers the following two Hyperledger certifications: The Certified Hyperledger Fabric Administrator (CHFA) and The Certified Hyperledger Sawtooth Administrator (CHSA), both of which are highly regarded in the industry. Hyperledger Foundation is in the process of creating Hyperledger Developer certification program, which may be released in early or middle of 2020. In short, by taking our hands-on online Hyperledger class, you would be able to obtain CHFA certification.
This recipe is written by Brian Wu who is our senior Hyperledger instructor in Washington DC. His Hyperledger Cookbook with 40+ hands-on recipes is highly recommended.

Related Training Courses

Hands-on Node.JS, MongoDB and Express.js Training
Advance JavaScript, jQuery Using JSON and Ajax
Learn Hands-on Blockchain Ethereum Development & Get Certified in 30 Hrs
Learn Blockchain Hyperledger Development & Get Certified in 30 Hrs
Become Blockchain Certified Security Architect in 30 hours
Blockchain Certified Solution Architect in 30 hours
Introduction to Python Programming
Object Oriented Programming with UML


Private and Custom Coding Classes

We offer private coding classes for beginners online and offline (at our Virginia site) with custom curriculum for most of our classes for $59 per hour online or $95 per hour in virginia. Give us a call or submit our Private Coding Classes for Beginners form to discuss your needs.


View Other Classes!