1

I see that to create channel, one needs to use configtxgen script to create channel artifacts, genesis block and channel config binary definition. What if I need to be able to programmatically and dynamically create new channels as needed? is there any api that could be invoked in a program, say nodejs, which would do what 'configtxgen' does?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Tara
  • 549
  • 2
  • 7
  • 14

2 Answers2

0

configtxgen is a tool that was created to faciliate development and testing using a largely pre-configured network, such as the sample applications. It is not required or intended to be used in a production context. You can use one of the Fabric SDKs to create channels, join channels, etc.

christo4ferris
  • 4,039
  • 1
  • 17
  • 30
  • Thanks. But if you refer to this link to create channel use the sdk, https://fabric-sdk-node.github.io/tutorial-channel-create.html , it is still using configtxgen to create the channel config binary file which needed by the the sdk create channel method. Is there other method or way to create the channel config binary file ? – Tara Oct 09 '18 at 13:33
  • correct, but that is optional. there is not presently another way to create the binary file. – christo4ferris Oct 09 '18 at 13:36
  • Okay,, I left out all the optional fields but createChannel return the following error: Missing config request parameter containing the configuration of the channel at Client._createOrUpdateChannel. It seems to still expecting the config field which suppose to be optional though. – Tara Oct 10 '18 at 00:35
  • @christo4ferris please see the irony in your replies: `configtxgen` is not intended for production, however there is no other way to create channel config binary files. So.. creating channels is not production-ready? :) – Paul Sep 16 '19 at 12:32
0

A channel configuration transaction that is generated with configtxgen is a file containing a protobuf of the common.Envelope message.

Assuming you use Java (although this should be possible in other languages as well), you can compile the protobuf to a native class. The Envelope message has been compiled to Java thanks to the Fabric Java SDK, so you can piggyback on the SDK to create the objects. Once you have the objects, you can get the ByteArray to create the ChannelConfiguration object that will be used to create a channel. This method doesn't require a configtx.yaml file at all, so you will need to keep track of organizations and their MSP IDs in the app.

Paul
  • 770
  • 1
  • 7
  • 12