Dumbonet: How to build a blockchain network with Hyperledger Fabric — Part II

If you are reading this, it means you succeeded in bringing up a fabric sample network, otherwise, go check the previous article.

First thing you should do, whether you are using Windows or Linux is to check all the prerequisites. Because you have already downloaded fabric samples, you can modify those files or start a new one in a new folder.

One thing that you will need if you choose to start from zero is a folder of platform-specific binaries:

Here you can see two fundamental tools, which are necessary to create a functioning transactional network with digital signature validation and access control:

cryptogen — which generates the x509 certificates used to identify and authenticate the various components in the network.

configtxgen — which generates the requisite configuration artifacts for orderer bootstrap and channel creation.

Here is, also, a short explanation for other tools:

The configtxlator command allows users to translate between protobuf and JSON versions of fabric data structures and create config updates.

Idexmigen is a tool that can generate Identity Mixer credentials in test environments. It was a feature in Hyperledger Fabric 1.3 release.

Fabric CA is a Certificate Authority for Hyperledger Fabric and consists of both a server and a client component. In very detailed documentation you can learn more about this, but let’s go back to two fundamentals tools and see what is happening behind.

Each tool consumes a configuration yaml file, within which we specify the topology of our network (cryptogen) and the location of our certificates for various configuration operations (configtxgen). Once the tools have been successfully run, we are able to launch our network.

Cryptogen consumes a file — “crypto-config.yaml” — that contains the network topology and allows us to generate a library of certificates for both the Organizations and the components that belong to those Organizations. Each Organization is provisioned a unique root certificate (“ca-cert”), that binds specific components (peers and orderers) to that Org. Transactions and communications within Fabric are signed by an entity’s private key (“keystore”), and then verified by means of a public key (“signcerts”). You will notice a “count” variable within this file. We use this to specify the number of peers per Organization — in our case, it’s two peers per Org.

After we run the tool, the certs will be parked in a folder titled “crypto-config”:

Configtxgen consumes a file — “configtx.yaml” — that contains the definitions for the sample network. There are three members — one Orderer Org (“OrdererOrg”) and two Peer Orgs (“Org1” & “Org2”) each managing and maintaining two peer nodes. This file also specifies a consortium — “SampleConsortium” — consisting of our two Peer Orgs.

Pay specific attention to the “Profiles” section at the top of this file. You will notice that we have two unique headers. One for the orderer genesis block — “TwoOrgsOrdererGenesis" — and one for our channel — “TwoOrgsChannel”. These headers are important, as we will pass them in as arguments when we create our artifacts. This file also contains two additional specifications that are worth noting.

Firstly, we specify the anchor peers for each Peer Org (“peer0.org1.example.com” & “peer0.org2.example.com”). Secondly, we point to the location of the MSP directory for each member, in turn allowing us to store the root certificates for each Org in the orderer genesis block. ✔This is a critical concept. Now any network entity communicating with the ordering service can have its digital signature verified.

This function will generate the crypto material and our four configuration artifacts, and subsequently, output these files into the “channel-artifacts” folder.

You can leave all other files the same as in first-network from fabric-samples. We will add one more script which we will need later in our final startDumbonet.sh script. It’s called purge.sh:

As you saw, you have files for adding one more organization to this network (Org 3). You can add as many as you wish. Feel free to play 😎We will, for this purpose, stick with two.

See? Setting network is much easier with free fabric samples. Next step is to write our chaincode. Since Hyperledger Fabric release 1.3. you can, besides Go and Node.js, write chaincode in Java programming language. Choose wisely!🦉 Because our server is written in Node.js, we will use, also, Javascript for chaincode.

In the next article, we will show you how to write a smart contract for one asset- Inquiry and you can later create one more, for asset Quotation. Good luck with setting network and see you in the next article about chaincode. 🤞

--

--