This content is no longer being updated or maintained. The content is provided “as is.” Given the rapid evolution of technology, some content, steps, or illustrations may have changed.
The Hyperledger Fabric first-network sample (variously called the "Build Your First Network" sample and the "e2e_cli" sample) showcases a fully scripted and end-to-end automated example of a basic blockchain use case tutorial sample. The sample provisions a Hyperledger Fabric blockchain network, deploys a smart contract (chaincode-Example02) application to the running network, and runs transactions against the deployed chaincode.
The provisioned Hyperledger Fabric blockchain network consists of two organizations, two peers per organization, and a single Solo ordering service. The network supports automatic provisioning of cryptographic material for peer and orderer organizations, automatic provisioning of channel artifacts, and channel joining by participating organizational peers.
In this tutorial, we show you how to add a third organization to an application channel with its own peers to an already running Hyperledger Fabric blockchain network, and join it to the channel.
Introducing the configtxlator tool
The configtxlator tool provides a true stateless REST API, independent of the SDK, to simplify configuration tasks in Hyperledger Fabric blockchain networks. The tool converts easily between different equivalent data representations/formats. For example, in one mode of tool operation, the tool performs conversions between the binary protobuf format to a human-readable JSON textual format, and vice-versa. Additionally, the tool can compute configuration updates based on the differences between two different sets of configurations transactions.
Set up your environment
Want to use your own Certificate Authority?
See how to configure, test, and validate the Hyperledger Fabric "first-network" sample with custom-provisioned cryptographic material that you obtain from a well-known external certificate authority for root and intermediate certificates.
For command-line configuration updates, make sure you have at least Version 1.4.1 or above of Hyperledger Fabric installed. These versions feature newer/enhanced capabilities coupled with numerous defect fixes. You can learn about the detailed features and defect fixes in each of version release notes documents.
Bring up first-network and make sure it is running correctly as shown in Figure 1.
Get into the CLI container interactively and check the peer version using the commands shown below inside the container:
docker exec -it cli /bin/bash
peer version
Show more
Figure 2. Verification of peer binary version inside the CLI container
Make sure the JQ tool is installed and working correctly in the CLI container by running the following commands inside the CLI container:
jq -version
jq
Show more
Figure 3. Running commands inside the CLI container to verify JQ tool installation
Make sure the configtxlator tool is available, verify the tool version, start the tool in the background, and verify that the tool is running correctly in the background, inside the CLI container, by running the following commands:
configtxlator version
configlator start &
netstat -ap
Show more
Figure 4. Verification and successful running of configtxlator tool inside the CLI container
1
Retrieve the current configuration
Set and verify the following environment variables by running the following commands inside the CLI container:
Figure 9. Extract the payload portion of the configuration JSON object and verify
4
Create the new configuration by editing the extracted config section
Run the following command inside the CLI container to create a new configuration JSON object that unites the current configuration and the new organization, Org3, which is added to the consortium dynamically as shown in Figures 10 and 11:
Figure 10. Create a new configuration JSON object file
Figure 11. New configuration JSON object as viewed in the JSON editor with Org3 being added to the consortium
5
Encode both the original and modified configurations using configtxlator
Run the following command inside the CLI container to encode the original configuration JSON object as a configuration object protobuffer, as shown in Figure 12:
Figure 12. Encode the original configuration JSON object as a configuration object protobuffer
Run the following command inside the CLI container to encode the updated configuration JSON object as a configuration object protobuffer, as shown in Figure 13:
Figure 13. Encode the updated configuration JSON object as a configuration object protobuffer
6
Send them to configtxlator to compute the config update delta
Run the following command inside the CLI container to determine the configuration update change, given the original and updated configuration protobuffer objects -- and then verify the resulting computed configuration update object, as shown in Figure 14:
Figure 14. Compute the configuration update change delta and verify the configuration update protobuffer object
7
Decode the config update and wrap it up into a config update envelope
Run the following command inside the CLI container to convert the configuration update object into a human-readable JSON object, and verify it as shown in Figure 15:
Figure 15. Convert and verify the configuration update object as a JSON object
Run the following command inside the CLI container to wrap the configuration update JSON object into an envelope, resulting in a configuration JSON object with an envelope, and verify it as shown in Figure 16:
Figure 16. Configuration update JSON object with envelope
8
Create the new config transaction
Run the following command inside the CLI container to encode the configuration update JSON object with envelope to a configuration object with envelope as a protobuffer, and verify it as shown in Figure 17:
Figure 17. Encode configuration update JSON object with envelope to configuration object with JSON as a protobuffer
9
Update the channel by submitting the new signed config transaction
Run the following commands inside the CLI container to set the environment of Org1, sign the configuration update transaction, and verify signing to be successful, as shown in Figures 18 and 19:
Figure 18. Org1 administrator role successfully signing the configuration update transaction
Figure 19. Org1 administrator role successfully submitting the configuration update signed transaction
Run the following commands inside the CLI container to set the environment and verify for Org2, as shown in Figure 20 (you can issue all of these commands at once):
Figure 20. Setting and verification of the Org2 environment inside the CLI container
Run the following command inside the CLI container to dynamically update the configuration by submitting the transaction and verifying its success, as shown in Figure 21:
Figure 21. Dynamically updating the configuration by submitting update transaction
Run the following command inside the CLI container to retrieve the successfully updated configuration block from runtime and verify successful operation, as shown in Figures 22 and 23:
Figure 22. Retrieve updated configuration from runtime
Figure 23. Verify updated configuration from runtime
Run the following command inside the CLI container to decode the updated configuration object into human-readable JSON format and search for the Org3MSP token to confirm successful dynamic update of the configuration, as shown in Figure 24:
Figure 24. Decoding and verifying successful dynamic update of configuration
Run the following commands inside the CLI container to list and verify the dynamic configuration update task artifacts in JSON and protobuffer formats, as shown in Figure 25:
file*.pb
file *.json
Show more
Figure 25. Listing and verifying dynamic configuration update task artifacts in JSON and protobuffer formats
Run the following command outside of the CLI container to confirm the successful update of the configuration dynamically, as shown in Figure 26:
docker logs -f peer0.org1.example.com
Show more
Figure 26. Verifying successful configuration update dynamically from container log
Run the following command from outside of the CLI container to determine the locations of the container logs in JSON format for detailed review, verification, and analysis, as shown in Figure 27:
Figure 27. Determining the location of the container JSON formatted log files
Conclusion
Congratulations! You have successfully used the encoding and decoding features of the configtxlator tool to add a third organization with its own peers to the application channel of an already running Hyperledger Fabric blockchain network. You have verified and validated the successful addition of this new organization to your channel configuration.
Now that you know how to add an organization to an existing Hyperledger Fabric blockchain network consortium, you can now add this new organization to a channel so that the organization can fully participate in blockchain network activities. You are also ready to review, understand, and work through the tutorial Adding an Org to a Channel in the Fabric docs to achieve the above outcome.
Acknowledgments
The authors gratefully thank IBM Blockchain development/research professionals, IBM digital content development editorial and graphics professionals, and IBM executive/management team for giving us opportunity to work on this content.
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review your cookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.