I developed a simple Blockchain App as part of the Hackathon in India Dapp conference held at Bangalore in May 2019. The Idea was to Design a private Blockchain to Decentralize Flight information Database of the Airlines.
Private Permissioned Blockchains is the new Buzzword, With Linux Foundation’s Hyperledger project the transactional networks of today are completely revolutionized and this project has created standard methods for establishing identity on the network, executing transactions, and storing data.
All the code can be found on my Github here
Hyperledger Fabric is private and permissioned. Rather than an open permissionless system that allows unknown identities to participate in the network the members of a Hyperledger Fabric network enroll through a trusted Membership Service Provider (MSP).
Setting up Development environment ==> Click
Asset==> Flight details like Flight Number, Location, Working state, Flight Type, EmployeeId of the updater, Description.
Participants==> Employees responsible for updating the information.
Transaction==> Updating Location, Updater, Working state and Flight number.
To get Skeleton code and proper file structure run:
The Transaction logic is pretty simple, We are just changing the old values to new values and updating the employeeId.
Permissions.acl is a file to assign rights and duties to the participants, peers and admins. For Simplicity I have given all the rights to Admin and System.
Then we create the Banana file(.bna) using:
composer archive create -t dir -n .
In the same directory as the above files we’ll get a firstname.lastname@example.org file which is used to deploy the model on the running instance of hyperledger fabric for a single organisation.
Before continuing make sure that all the previous Network cards are removed from your wallet run: Source
rm -fr ~/.composer
We need to build a connection profile, creating a connection.json file to define and specify all of the information required to locate and connect to the Hyperledger Fabric network, for example the host names and ports of all of the Hyperledger Fabric network components.
I’m creating a single peer(peer0.org1.example.com) the request port is 7051, Here we have specified our single CA(ca.org1.example.com) using the hostname localhost and the CA port 7054, Here, Our single orderer node (orderer.example.com) using the hostname localhost and the orderer port 7050 and we also label this as orderer.example.com. The orderers object can contain multiple orderer nodes.
I have also specified the total organisation the peers the CA the orderer and channels along with client section and the timeout length to wait before committing.
Now we look for the Private and public key of the admin which were generated after running ./startfabric.sh We then copy those keys to our project directory, And now we are ready to create our Business network card for the Hyperledger Fabric administrator.
composer card create -p connection.json -u PeerAdmin -c Admin@org1.example.com-cert.pem -k 114aab0e76bf0c78308f89efc4b8c9423e31568da0c340ca187a9b17aa9a4457_sk -r PeerAdmin -r ChannelAdmin
- -c This is the path to the certificate file for the user Admin@org1.example.com
- -k This is the path to the private key file for the user Admin@org1.example.com
- -r We specify which roles the user has
Next, We import the Business card into our wallet by running
composer card import -f PeerAdmin@Airline-network.card
Installing the Hyperledger Composer business network onto the Hyperledger Fabric peer nodes
composer network install -c PeerAdmin@Airline-network -a email@example.com
Starting the Blockchain
composer network start --networkName airline-network --networkVersion 0.0.1 -A admin -S adminpw -c PeerAdmin@Airline-network
When a blockchain business network is deployed, you must create at least one participant who will be a blockchain business network administrator. This participant is responsible for onboarding other participants into the blockchain business network. Here, we are specifying that we want to create a single blockchain business network administrator called admin.
-S specifies that our blockchain business network administrator admin will use an enrollment secret of adminpw to request a certificate and private key from the CA (Certificate Authority). When you specify this option, the name specified for the business network administrator must be an existing enrollment ID for a user that is already registered with the CA.
Importing the business network card for the business network administrator:
composer card import -f firstname.lastname@example.org
composer network ping -c admin@airline-network
Now we have successfully deployed blockchain business network to an instance of Hyperledger Fabric for a single organization, including generating the necessary Hyperledger Composer configuration.
Let’s generate a REST server:
NOTE: Specify if you want to enable event publication over websockets=Yes
We can Generate A skeleton Angular 4 Application:
This will create a proxy to the REST server and an app.js running npm start on that folder, And ultimately serve the Angular Application on http://0.0.0.0:4200/
We can add Assets, Participants and can invoke a Transaction all from this Angular 4 application,
Adding an Asset AI123 From Bengaluru due to arrive in Delhi.
Updated by emp01
With Functional Working State
Adding a Employee with EmployeeID emp01
I have also added another employee with EmployeeID of emp02
Invoking a Transaction and Committing it to the ledger
After the Commit we have Flight No: AI456, Location: Delhi, Working State: Non Functional and UpdatedBy: emp02
For any Queries and Doubts leave a comment if you liked the blog clap clap and clap!
Deploying a Hyperledger Composer blockchain business network to Hyperledger Fabric. was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.