This page contains example bash commands and scripts to generate the following interoperability artefacts:

  1. Join Request common.ConfigGroup JSON file based on a Fabric peer organisation. This can be send to a channel member to request to join the channel.
  2. Channel Update protobuf file based on the current channel configuration and the join request. This can be used to gather signatures and finally update the channel.

Create common.ConfigGroup for Join Request

In this section the artefact for the join request will be created.

  1. Locate your fabric peer organisation's cryptographic material . The directory structure should look like this:

    • configtx.yaml

    • crypto-config

      • peerOrganizations
        • example-org.com
          • ca
          • msp
          • peers
          • tlsca
          • users
  2. Find or create a configtx.yaml file that contains at least the information about the organisation you want to join to the channel. An example configuration file looks like this:

    configtx.yaml
    ---
    Organizations:
        - &Org1
            Name: ExampleOrg
            ID: ExampleOrg
            MSPDir:  crypto-config/peerOrganizations/example-org.com/msp
            Policies: &Org1Policies
                Readers:
                    Type: Signature
                    Rule: "OR('ExampleOrg.member')"
                Writers:
                    Type: Signature
                    Rule: "OR('ExampleOrg.member')"
                Admins:
                    Type: Signature
                    Rule: "OR('ExampleOrg.admin')"
            AnchorPeers:
                - Host: peer0.example-org.com
                  Port: 7051
  3. Create the ConfigGroup JSON using the configtxgen printOrg function. Execute the following command in the directory of your configtx.yaml:

    configtxgen -printOrg ExampleOrg > configGroup.json
  4. Send the configGroup.json to one of the channel members.


Create common.ConfigUpdate (channel update)

In this section, the channel update for a new channel member will be created based on the join request. This can be used to make a new proposal via the management chaincode.

  1. Save the join request JSON file with the name configGroup.json.

  2. Use the peer CLI or one of the Fabric SDKs to download the latest CONFIG block of your channel and save it as channel_block.pb.

  3. Based on the current channel configuration and the join request, you can create a channel update using the configtxlator and jq. The following file contains example steps to extract the required information and calculate the final channel update that can be used to join the new organisation to the channel.

    # Decode the block to JSON to be able to extract the config and update it later.
    configtxlator proto_decode --type common.Block --input channel_block.pb --output channel_block.json
    
    # Extract the channel config (assuming the CONFIG transaction is the first transaction).
    cat channel_block.json | jq '.data.data[0].payload.data.config' > channel_config.json
    
    MSPID=$(cat configGroup.json | jq -r '.values.MSP.value.config.name')
    CONFIG=$(cat configGroup.json)
    
    # Insert the new config of the organization into the channel config.
    cat channel_config.json | jq ".channel_group.groups.Application.groups.${MSPID} = ${CONFIG}" > updated_config.json
    
    # Encode the original and updated config block to proto to calculate the diff.
    configtxlator proto_encode --type common.Config --input channel_config.json --output channel_config.pb
    configtxlator proto_encode --type common.Config --input updated_config.json --output updated_config.pb
    
    # Calculate the channel update based on the created artifacts.
    configtxlator compute_update --original channel_config.pb --updated updated_config.pb --channel_id=my-channel --output channel_update.pb
  4. The resulting channel update (channel_update.pb) can now be send to the management chaincode that runs on the joined channel to create a new proposal.