Building small blockchain application using IBM BLUEMIX
Description: Technical process and step by step representation of small app in Blockchain. With e.g.
IBM is famous for implementing Open Cloud Architecture both for close end applications and applications which offer the privilege of adding up. Blockchain application having these features is something that is best collaborated through IBM Bluemix. To make things clear here, IBM Bluemix is a cloud based implementation of IBM which enables the rapid creation, deployment, and management of cloud applications. We saw many case studies related to IBM Blockchain
On the other hand, Blockchain application is made through blocks of application where blocks can only be added when all Bitcon transactions are executed in a single block. It is a public ledger which grows constantly with complete blocks and thus it is both open end and close end.
Deploying of Bluemix
In order to deploy Bluemix into the Blockchain application, there are some pre-requisites. Some prior installations are required namely:
- NodeJS v6.x: This is an improved version of Node v6 offering better reliability and security to its user.
- Git: If you are handling a very large project and need speed and efficiency using Git as a free and open source distribution can be quite fruitfull.
- Docker: Docker is meant for providing extra abstraction and automation of operating-system-level virtualization on Windows and Linux.
How to Deploy Bluemix
In order to deploy Bluemix, you first need to determine the command window where you want Bluemix to run. You need to open up a terminal window to the Git where you can put in the code. Then you have to install the required module of npm and update the configuration file. Next it would be a method of connecting a non-defaultNodeJS server and non-default setup local peer.
Step by step representation of small app in Blockchain.
- Make note of prerequisites
Clone the repository: link git clone https://github.com/IBM-Blockchain/car-lease-demo.git
- Installing npm required modules
- Updating the configuration files:
Make sure you do the changes mentioned below in the configuration.js file, before you deploy in your local environment.
config.networkProtocol = 'https';
config.appProtocol = 'https';
config.hfcProtocol = 'grpc';
- Connecting to a non-default NodeJS server
- Connecting to a non-default setup local peer
- Connecting to an external Bluemix Peer
- Running the application
- Retrieving Logs
docker logs -f DOCKER_ID
Car Lease Demo
Here is an example where blockchain application is used along with IBM Bluemix. Here Hyperledger Fabric version 0.6.1 is used in the starter plan. Vehicles can be modelled using blockchain technology. Here is an example of the same.
Deploying the demo: In order to deploy the demo in the local environment, check out the instructions here.
Application overview: This application has been designed to show how assets can be modeled on the Blockchain and the application uses an example of car leasing.
In the scenario, the attributes given below are used to model the vehicles using Blockchain technology:
|V5cID||Unique string formed of two chars followed by a 7 digit int, used as the key to identify the vehicle|
|VIN||15 digit int|
|Owner||Identity of participant|
|Status||Int between 0 and 4|
|LeaseContractID||ChaincodeID, currently unused but will store the ID of the lease contract for the vehicle|
This application helps the participants to interact with the vehicle assets by creating, updating and transferring as per the permissions. The participants are:
|Regulator||Create, Read (All vehicles), Transfer|
|Manufacturer||Read (Own vehicles), Update (VIN, Make, Model, Colour, Reg), Transfer|
|Dealership||Read (Own vehicles), Update (Colour, Reg), Transfer|
|Lease Company||Read (Own vehicles), Update (Colour, Reg), Transfer|
|Leasee||Read (Own vehicles), Update (Colour, Reg), Transfer|
|Scrap Merchant||Read (Own vehicles), Scrap|
There is a close interaction between blockchain and IBM Bluemix when used properly. The deployment part is always quite important and at the same time the requirements have to be kept into the mind of the users. You have to understand that the blocks are already complete at the time of chaining them and further change in pattern may require some thoughts.
This demonstration allows a view of the ledger which saves all interactions that the above participants have with their assets. A regulator can view every transaction occurred with the help of the ledger view. It also shows who tried to make what change in the vehicle and when they tried to change. This view also lets the user to keep track of transactions that the particular user was involved with, in addition to showing the relations with the assets they own now before they owned them.
Example: A user can view when it was created.
Application scenario: This scenario runs through the lifecycle of a car that has the following stages:
- Lease Company
- Scrap Merchant
- The regulator creates the Vehicle as a template.
- The manufacturer gets the Vehicle template that is transferred to him.
- The vehicle template is updated by the manufacturer who then defines it as a vehicle by assigning it a model, make, reg. etc.
- The vehicle is transferred to the dealership by the manufacturer for sale.
- The vehicle is then transferred to a lease company by the dealership.
- The vehicle is then transferred to the leasee by the Lease company. It is not actually leased but the application shows what might happen if the lease ended and if the purchase option was activated by the leasee.
- The vehicle is then transferred to a scrap merchant by the leasee.
- The vehicle is scrapped by the Scrap merchant.