Hyperledger Fabric Network Setup | Understand configtx.yaml file – Part 1

Hyperledger Fabric Network Setup | Understand configtx.yaml file – Part 1

This post is part of Hyperledger Fabric network setup as mentioned below.

  1. Understand crypto-config.yaml file : Used to create cryptography material.
  2. Configtx.yaml file: Used to create genesis block and channel.
    1. Understand the structure of configtx.yaml file.
    2. Run configtxgen command to create genesis and channel artifacts.
  3. Understand docker-compose.yaml file: Used to create docker container.

In our last blog, we discussed about crypto-config.yaml file and understand the structure of that file and then saw how to use that file to create cryptography material. In case you missed that, you can click here to read that article.

Now let's move to next step and that is understanding of configtx.yaml file. We split this post into two parts , first part will cover the details about configtx.yaml file and in second part, we will show you how to generate genesis and channel artifacts using that configtx.yaml file.

Let's deep dive and understand configtx file.yaml structure in detail.

Structure of configtx.yaml file

configtx.yaml file consist of

  • organizations section
  • orderers section
  • applications section
  • capabilities section
  • profiles section


Organizations Section in configtx.yaml file

This section contains the organization details and that organization can be orderer or peer one. Below is one of the example from first-network sample.

As you see in below structure, very first tag is "Organizations:" and under that you can define any number of organizations as per the requirement.

As you see each organization has name, ID and MSPDir. Here MSPDir is location where cryptography material for that organization is stored.

It also has host and port details for it's anchor peer as well.


    - &OrdererOrg
        Name: OrdererOrg
        ID: OrdererMSP
        MSPDir: crypto-config/ordererOrganizations/example.com/msp

    - &Org1
        Name: Org1MSP
        ID: Org1MSP
        MSPDir: crypto-config/peerOrganizations/org1.example.com/msp

            - Host: peer0.org1.example.com
              Port: 7051

    - &Org2
        Name: Org2MSP
        ID: Org2MSP
        MSPDir: crypto-config/peerOrganizations/org2.example.com/msp

            - Host: peer0.org2.example.com
              Port: 7051


Orderer Section in configtx.yaml file

This section contains the details about orderer. This helps to create genesis block as well.

OrderType: This can have value as "solo" or "kafka". solo is used during development and kafka is used in production environment.

Addresses: This contains host and port details of orderer.

BatchTimeout: wait time before creating a batch. Orderer job is to create a batch of transactions so this is wait time for that.

Max Message Count: The maximum number of messages to permit in a batch

Absolute Max Bytes: The absolute maximum number of bytes allowed for the serialized messages in a batch.

Preferred Max Bytes: The preferred maximum number of bytes allowed for the serialized messages in a batch. A message larger than the preferred max bytes will result in a batch larger than preferred max bytes.

Orderer: &OrdererDefaults

    OrdererType: solo
        - orderer.example.com:7050
    BatchTimeout: 2s
        MaxMessageCount: 10
        AbsoluteMaxBytes: 99 MB
        PreferredMaxBytes: 512 KB


Application section in configtx.yaml file

Application is being referred in the genesis block. As shown below organizations is list of orgs which are defined as participants.

Application: &ApplicationDefaults

    # Organizations is the list of orgs which are defined as participants on
    # the application side of the network

Capabilities section in configtx.yaml file

Capabilities is new feature in Hyperledger Fabric 1.1. The idea behind this is to avoid any impact to the network when there are different version of Fabric code running on nodes and everyone has same view of transaction.

Capabilities of different types as mentioned below.

Channel: these capabilities apply to both peer and orderers and are located in the root Channel group.
Orderer: apply to orderers only and are located in the Orderer group.
Application: apply to peers only and are located in the Application group.

    Global: &ChannelCapabilities
        V1_1: true
    Orderer: &OrdererCapabilities
        V1_1: true
    Application: &ApplicationCapabilities
        V1_1: true


Profile section in configtx.yaml file

Last and important section in configtx.yaml file is profile section. It consist of mainly two parts, one is genesis block details and second is channel details. Let's understand it with example.

TwoOrgsOrdererGenesis refers to genesis block and has required details under that. It contains capabilities of block, orderer details ( organization and capabilities), consortium details ( peer organizations).

TwoOrgsChannel refers to channel that helps to create required channel.


            <<: *ChannelCapabilities
            <<: *OrdererDefaults
                - *OrdererOrg
                <<: *OrdererCapabilities
                    - *Org1
                    - *Org2
        Consortium: SampleConsortium
            <<: *ApplicationDefaults
                - *Org1
                - *Org2
                <<: *ApplicationCapabilities
Inquire Now
close slider