1. Get Your Audience Involved

Are you starting to plan out your social media marketing strategy? If so, these three social media marketing tips will help you kick start off on the right foot. UGC or user generated content is an…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Hyperledger Fabric CA

For the last two days, we have seen various capabilities of Hyberledger fabric. Today we are going to get into setup the blockchain app using Hyperledger Fabric.

The main focus is set the mindset and to build confidence on a setup of the Hyperledger Fabric system.

We are going to pull the latest code for sample app from Github, startup scripts, configuration and testing. End of this article we could sense the fully functional blockchain app.

Prerequisites

Installers development is in progress, so we are going to use the Fabric docker images.

Steps to download the binaries and docker images

It retrieves four platform specific binaries in that directory with bin sub directory.

You need to add that bin to the PATH, using

SDK’s are important for the clients, to connect with Fabric network. To deploy the smart contract, to do function invocation in the smart contract. All the connectivity between Fabric network and client application done through SDK’s.

There are two types of SDK’s,

Fabric also provides the Certificate Authority service. It is used to generate the certificates, private and public keys.

Because each fabric node or client needs to be configured with private and public keys. So that all parties involved in the fabric network are known identities.

We are going to use,

Fabric” + “NodeJs

Steps involved in running the first app

Starting the test Hyperledger Network

In this, we can see fabcar is another sub directory, this is the application we are going to deploy to the network.

Now use the startFabric.sh script to launch the network.

Here you can see steps happen in the start script,

Issue a docker ps command to reveal the processes started by the startFabric.sh script.

fabric readdocs

So far we have created the test network, deployed the smart contract. And blockchain is pre populated with 10 data. You can see all happens in the start script console.

Now are going to use the NodeJs SDK to retrieve and update data to the blockchain.

credit: fabric read docs

Inside the fabcar directory, run the following command.

You can see the query.js in that directory. if you run the below command

The result will be like,

If we see the query.js, we can see the configuration to connect the fabric network from the sdk

Also also below, we can see the query constructor.

In the same directory of fabcar, we can see the another directory with chaincode, chaincode/fabcar/fabcar.go is the deployed smart contract(chain code) to the network. There the function for queryAllCars is written.

2. Querying the particular car in the blockchain, in the same query do the changs to the request object.

save the program and call

You should see the following:

3. Updating the ledger.

Now open the “invoke.js” file. Which is used to insert and update data to the blockchain using nodejs SDK.

To insert data, change the request object to

Save it and run the program:

output will be,

To update the data, change the request object in “invoke.js” to

Save it and run the program:

Output is,

In this part we have successfully run a test network, query and update data on the blockchain. Next section we can see the details of forming the network and smart contract code.

Please find the other days of Hyperledger fabric

Day1 — What is Hyperledger and Fabric

Day2 — Concepts of Hyperledger Fabric

Day3 — Running the sample app

Day4 — How to start and configure network

Day5 — Manual, step by step for sample application building

Day6 — What is chaincode

Day7 — Chaincode for Developers

Add a comment

Related posts:

Stop the Violence

The changing world along with new inventions and discoveries has yet changed the tradition and cultures embedded upon the people of a country. The outer cover of book can change but will still be…

LA MADRE FERIA

The Mother Feria comenzó como una iniciativa de Paula Barrionuevo ante la situación de desempleo que atravesaba. Funciona todos los domingos desde hace dos años. Ya van 26 ferias realizadas donde la…

16 Signs of an Avoidant or Unavailable Partner

Intimate relationships require balancing closeness and distance, interdependence and autonomy. Healthier relationships flow between these poles with both partners seeking either side of the spectrum…