Building Blockchain network with Hyperledger Fabric and Composer

In one sentence, Blockchain is a trusted distributed ledger that records transactions that occur in the network. Why do we need it?

Blockchain technology revolutionized the traditional business networks and replaced the old inefficient, expensive and vulnerable systems.

In my previous blogpost, I explained how to build smart contracts for the Ethereum Blockchain. Now, I will give a brief overview how to do it using Hyperledger fabric and composer.

Hyperledger Fabric is permissioned network that provides framework for Blockchain applications. Unlike other Blockchain implementations, it satisfies all four elements of a Blockchain for business. It is permissioned network, the transactions are confidential, it does not rely on cryptocurrency and it is programmable.

Hyperledger composer is a web-based interface that simplifies the modeling and the testing of the network. Composer enables us to deploy an archive of the business network on the fabric network. This archive consists of three required files:

  • the network model – which defines the resources
  • script file – that defines the business rules
  • access control file- that contains rules for different participants on the resources of the network.

In this application I will set up one hotel payment processed by REST API server, that will allow client-side software to interact with the business network.

After installation of composer tools and Hyperledger Fabric Runtime, we generate peerAdmin card. The owner of the card has the privilege of managing the business network on the fabric:

Creating business network with Yo-generator


Yo is used to set up sample business network. Besides that, generator-hyperledger-composer can generate model, loopback or Angular application.

To model the network, we should open the Model file and define the network resources and transactions in them.  Then, we write the logic of the transaction in the script file and define the rules in the permissions file.

After the coding is finished, we should:

-Create the archive

composer archive create  –sourceType dir –sourceName ../


-Install the BNA

composer network install -a hotel@0.0.1.bna -c PeerAdmin@hlfv1


-Start the BNA

composer network start -c PeerAdmin@hlfv1 -n hotel -V 0.0.1 -A admin -S adminpw


-Import the card that was generated

composer card delete -c admin@hotel


Testing the business network


Now, when our network is up and running and we have an archive of it, we can upload it to the Composer playground and test it there.

Navigate to https://, select deploy new business network and upload the archive file.

We define our assets. First, we create the participants- our account holders. Guest account holder and hotel account holder.

Then we define the assets- their accounts. Guest account with budget 15000 and hotel account with  budget 50000.

Then we submit the transaction. We define the account that pays and the account that receives the money and the amount of payment, 1000.

After the transaction is submitted, we can see the new state in the assets window.

Hotel’s account now has 51000 and guest’s account has 14000, which means the transaction was successful.

Generate Rest Service

Another way to interact with the business network is with Rest Server. Type composer-rest-server in your terminal and specify admin@hotel.card, select never use namespace and continue with the default settings.

Follow the link and you are navigated to the rest server where you can play with the network components similarly like in the composer playground.



The purpose of Hyperledger is to provide an environment for facilitating commercial adaptation of Blockchain and easy to use API-s that enable simple development and interoperability.

Although new and challenging, the concepts for simple, modular and easy to grasp for IT and business professionals.

If your business network needs managing of relationships, transaction tracking, unbiased control, increased transparency or your system is prone to errors due to manual processes, Hyperledger Blockchain can make a huge difference for you!