Config Generator In Hyperledger Fabric

Every Ledger starts with a transaction kept inside the block but what will be the first block? Well, the answer is genesis block. Now, another question how to generate this genesis block? For this part we can use the configtxgen tool to generate the initial or genesis block.
The tool is primarily focused on generating the genesis block for bootstrapping the orderer, but it is intended to be enhanced in the future for generating new channel configurations as well as reconfiguring existing channels.

This tool takes the parameter in form of the configtx.yaml file. You can find the sample configtx.yaml file under the directory fabric/sampleconfig/configtx.yaml on github.

Lets explore the configtx.yaml file. This file mainly contains the following sections:-

  • The Profiles section.
  • The Organizations section.
  • The default sections.

The Profile Section :- Profiles can make a good starting point for construction a real deployment profile.Profiles may explicitly declare all configuration, but usually inherit configuration from the defaults Section.

Sample Profile Configuration:-

The Organizations Section :- This section includes a single reference to the MSP definition. Each element in the Organizations section should be tagged with an anchor label such as & orgName which will allow the definition to be referenced in the Profiles sections.

Sample Organizations Configuration:-

The Default Section :- There are default sections for Orderer and Application configuration, these include attributes like BatchTimeout and are generally used as the base inherited values for the profiles.

Sample Default Configuration:-

Generating the genesis block for the orderer We can use the configtxgen tool to generate the genesis block for the orderer.

configtxgen -profile -outputBlock orderer_genesisblock.pb

An orderer_genesisblock.pb file is generated to the current directory.This genesis block is used to bootstrap the ordering system channel, which the orderers use to authorize and orchestrate creation of other channels. By default, the channel ID encoded into the genesis block by configtxgen will be testchainid. It is recommended that you modify this identifier to something which will be globally unique.

Creating the Channel For creating the channel we need the following things:-

  • Profile Name
  • Channel Name
  • Tx FileName

configtxgen tool is needed for the creating of channel. We can use the following command to generate the channel.

configtxgen -profile -channelID -outputCreateChannelTx

This will output a marshaled Envelope message which may be sent to broadcast to create a channel.

We can also review the configuration using the following fashion :-

  • Inspecting the Block
  • Inspecting the Channel

Inspecting the Block:-

An Inspect flag is available for inspecting the Block status. -inspectBlock used with the configtxgen tool.

configtxgen -inspectBlock

The output will the JSON that contains all the relevant information required for the Inspection of the block.

Inspecting the Channel:-

An Inspect flag is available for inspecting the Channel status. -inspectChannelCreateTx used with the configtxgen tool.

configtxgen -inspectChannelCreateTx

The output will be the JSON that contains the information about the Channel.

You may even wish to combine the inspection with generation. For example:-

configtxgen -channelID foo -outputBlock foo_genesisblock.pb -inspectBlock foo_genesisblock.pb

Thats all for the Config Generator for the Transaction. Stay Tuned & Happy Coding 🙂

References:- HyperLedger Official Documentation



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at

Up ↑

%d bloggers like this: