⛓️Channel Creation

Here we will understand the Confixtx.yaml file and learn how to create channel.

Create Channel

  1. Set the Config Path

export PATH=${PWD}/../bin:${PWD}:$PATH
export FABRIC_CFG_PATH=${PWD}/configtx
export CHANNEL_NAME=mychannel
  1. Create the System Genesis Block and Channel Genesis block

configtxgen -profile TwoOrgsApplicationGenesis -outputBlock ./channel-artifacts/${CHANNEL_NAME}.block -channelID $CHANNEL_NAME
  1. Convert Block to JSON format to understand the data inside it.

configtxgen -inspectBlock ./channel-artifacts/mychannel.block > dump.json
  1. Copy some prerequisites

cp ../config/core.yaml ./configtx/.
  1. Create the Channel

Let's Export the Environment variables to provide Orderer access to our terminal.

export ORDERER_CA=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
export ORDERER_ADMIN_TLS_SIGN_CERT=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
export ORDERER_ADMIN_TLS_PRIVATE_KEY=${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key

Let's create a channel using "OSNADMIN" binary file.

osnadmin channel join --channel-id $CHANNEL_NAME --config-block ./channel-artifacts/${CHANNEL_NAME}.block -o localhost:7053 --ca-file "$ORDERER_CA" --client-cert "$ORDERER_ADMIN_TLS_SIGN_CERT" --client-key "$ORDERER_ADMIN_TLS_PRIVATE_KEY"
  1. Join the Organizational peers in the channel

First Let's join Org1 Peer.

To join the channel, our terminal needs access to peer, for that let's write a script which will set the environment variables.

Script Name: setOrgPeerContext.sh

Now let's source the script.

Let's join the peer now

Join Org2 Peer Now

  1. Update Anchor peer for Org1

  1. Update Anchor peer for Org2

That's it!

Last updated

Was this helpful?