Hyperledger Fabric: How to Setup Application from Scratch using Nodejs Series — Part 3

Setting up your own Network from Scratch

Image for post
Source: Google

Hey Guys, how are you all!,.. Happy to see that you are reading part 3 of this series!,. if you missed out my early series, I would recommend to read that first before you proceed further!. Else, you may not be able to follow this articles.

Part 1 -> Hyperledger Fabric: How to Setup Application from Scratch using Nodejs — Series 1 to ??

Part 2 -> Hyperledger Fabric: How to Setup Application from Scratch using Nodejs Series — Part 2

Ok, let’s get started.. In this article, we are going to setup our Hyperledger Fabric Network from scratch. To do that, we need to understand few files & it’s configuration.

First, we need to define who will do what role!, as I mentioned in my earlier article. Let’s make that also I assume that, you have followed my first article & have downloaded necessary binary files?..

Step 1: Go to “Fabric-Samples” folder , find binary files in Bin folder. Copy all those in your new folder(I name it as mynetwork)

Image for post
Image for post
Binary files in mynetwork folder

Step 2: Go to “Fabric-samples/first-network” folder, copy down crypto-config.yaml file into your mynetwork folder

Image for post
Image for post
Folder with “Crypto-Config-Yaml”

it’s time to deep dive this file & make the necessary changes..

This file basically has few components, first one is ORDERER (very important) component in fabric network, there are two types of Orderer. First one is “SOLO” & other one is “Kafka” based. SOLO is single orderer and using this in development environment is fine, but in production STRICTLY NO!.. you will end up loosing your data, when network is down.

Image for post
Image for post
crypto-config.yaml — Orderer section

Here, most of the names given are “User Defined”, so your identity(CA) will be created basis this names, so while mapping this orderer with respective fabric-images, you should use the same names/ca files. Best practice is that, use proper naming standards, so that it will be easy to identify which container belongs to which components.

In above image, “Name of the Orderer is “Orderer” & the domain is example.com (do not use any special characters).. So the final name for this Orderer will be “{{.Hostname}}.{{.Domain}}” and in our example it is “orderer.example.com”

Image for post
Image for post
Peer & Org Settings in Crypto-config.yml

Above image shows, that we have two Organization & peers for each org respectively. Let’s go one by one.

PeerOrgs -> indicates this section belongs to defining peers

Name -> Organization name, here it is Org1

EnableNodeOUS : true? indicates ability to classify identities as either a “client” or a “peer”. This allows you to create policies such as Org.peer and Org.client in addition to the existing Org.memberand Org.admin. If you enable this is cryptogen, it will generate MSPs which use this feature.

Template : count 2 , Indicates 2 peers will be created under this organization (org1), so the peer name will be like peer0.org1.example.com, peer1.org1.example.com

Users: count 1 , indicates one user identity will be created. In reality, or in production Fabric-CA does the job for us. It creates the identity for new users. But in development we will use CRYPTOGEN(Binary file)

Similarly for next peer(Org2).

In this file, we have seen how to setup Orderer, Peers, Organization & User. While defining your network, you will end up spending good amount of time in this file, since generating right identity & certificates matters the most.

Ok it’s all set , now it’s time to generate our certificates. Go to terminal & execute this command, you will see Org1.example.com & Org2.example.com as results

Image for post
Image for post
Results obtained after Cryptogen Command

Congratulations, you have created the certificates for those components successfully, now go to your directory & navigate through each folder & check how many folders/files it has created.

It is very important to understand, what each folder is & what it does, spend some good time to navigate through and understand the folder structure. (BUT DONT PLAY WITH IT :))

We have taken the very first step & it is successful, next we need to create our first block(Genesis) & define who is going to be our Anchor Peers right?.. Let’s meet in my next article.

Note: if you find this article interesting, give me a thumps-up(claps) & feel free to share this. Also, tag this series to get notified for next article.

Coinmonks

Coinmonks is a non-profit Crypto educational publication.

Sign up for Coinmonks

By Coinmonks

A newsletter that brings you week's best crypto and blockchain stories and trending news directly in your inbox, by CoinCodeCap.com Take a look

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Logeswaran Audhikesavan

Written by

Happy to learn, what I have experienced in Blockchain & Analytics Space, watch out www.blockchaindreamlab.com & www.zuiverinfotech.com

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Logeswaran Audhikesavan

Written by

Happy to learn, what I have experienced in Blockchain & Analytics Space, watch out www.blockchaindreamlab.com & www.zuiverinfotech.com

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store