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.
- npm: It is the package manager for JavaScript
- 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
npm install
- 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
./start.sh
- 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.
https://youtu.be/IgNfoQQ5Reg
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:
Attribute | Type |
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 |
Make | String |
Model | String |
Colour | String |
Reg | String |
Owner | Identity of participant |
Scrapped | Boolean |
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:
Participant | Permissions |
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:
- Regulator
- Dealership
- Leasee
- Manufacturer
- Lease Company
- Scrap Merchant
Stages:
- 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.
Component mode:
The demo is constructed with the help of a 3 tier architecture. With the help of a front end, a user communicates with the demo. This front end is given b y the NodeJS server in the mid tier. It makes HTTP requests to the NodeJS server with the help JavaScript code, which in turn has an API ([defined here](Documentation/API Methods.md)). This makes calls via HTTP to the HyperLedger fabric to get more information regarding the blockchain and also work together with the chaincode. Data on the chaincode interface can be found [here](Documentation/Chaincode Interface.md)