Create main channel

Only the Retailer should run the following commands from its Cloud9 terminal.

Bundle the member certificates together so that they can easily be downloaded and installed by each member.

cd
mkdir -p $HOME/retailer-admin-msp/cacerts
mkdir -p $HOME/retailer-admin-msp/admincerts
mkdir -p $HOME/supplier-admin-msp/cacerts
mkdir -p $HOME/supplier-admin-msp/admincerts
aws s3api get-object --bucket $BUCKET_NAME --key rtcacert.pem $HOME/retailer-admin-msp/cacerts/cacert.pem
aws s3api get-object --bucket $BUCKET_NAME --key rtadmincert.pem $HOME/retailer-admin-msp/admincerts/cert.pem
aws s3api get-object --bucket $BUCKET_NAME --key spcacert.pem $HOME/supplier-admin-msp/cacerts/cacert.pem
aws s3api get-object --bucket $BUCKET_NAME --key spadmincert.pem $HOME/supplier-admin-msp/admincerts/cert.pem
tar czf certs.tgz retailer-admin-msp supplier-admin-msp
aws s3api put-object --bucket $BUCKET_NAME --key certs.tgz --body $HOME/certs.tgz --acl bucket-owner-full-control

Create a channel configuration for the supply chain chaincode:

docker exec cli configtxgen -outputCreateChannelTx /opt/home/mainchannel.pb -profile MainChannel -channelID mainchannel --configPath /opt/home/

The output should look like:

2020-10-16 02:41:28.544 UTC [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-10-16 02:41:28.546 UTC [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /opt/home/configtx.yaml
2020-10-16 02:41:28.548 UTC [common.tools.configtxgen.localconfig] LoadTopLevel -> INFO 003 Loaded configuration: /opt/home/configtx.yaml
2020-10-16 02:41:28.548 UTC [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 Generating new channel configtx
2020-10-16 02:41:28.548 UTC [common.tools.configtxgen.encoder] NewChannelGroup -> WARN 005 Default policy emission is deprecated, please include policy specifications for the channel group in configtx.yaml
2020-10-16 02:41:28.548 UTC [common.tools.configtxgen.encoder] NewApplicationGroup -> WARN 006 Default policy emission is deprecated, please include policy specifications for the application group in configtx.yaml
2020-10-16 02:41:28.548 UTC [common.tools.configtxgen.encoder] NewApplicationOrgGroup -> WARN 007 Default policy emission is deprecated, please include policy specifications for the application org group  in configtx.yaml
2020-10-16 02:41:28.548 UTC [common.tools.configtxgen.encoder] NewApplicationOrgGroup -> WARN 008 Default policy emission is deprecated, please include policy specifications for the application org group  in configtx.yaml
2020-10-16 02:41:28.548 UTC [common.tools.configtxgen.encoder] NewChannelGroup -> WARN 009 Default policy emission is deprecated, please include policy specifications for the channel group in configtx.yaml
2020-10-16 02:41:28.548 UTC [common.tools.configtxgen.encoder] NewApplicationGroup -> WARN 00a Default policy emission is deprecated, please include policy specifications for the application group in configtx.yaml
2020-10-16 02:41:28.549 UTC [common.tools.configtxgen.encoder] NewApplicationOrgGroup -> WARN 00b Default policy emission is deprecated, please include policy specifications for the application org group  in configtx.yaml
2020-10-16 02:41:28.549 UTC [common.tools.configtxgen.encoder] NewApplicationOrgGroup -> WARN 00c Default policy emission is deprecated, please include policy specifications for the application org group  in configtx.yaml
2020-10-16 02:41:28.549 UTC [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 00d Writing new channel tx

Check that the channel configuration has been generated:

ls -lt ~/mainchannel.pb

The output of that ls command should look like:

-rw-r--r-- 1 root root 538 Jul 23 03:58 /home/ec2-user/mainchannel.pb

Then create the channel:

docker exec cli peer channel create -c mainchannel -f /opt/home/mainchannel.pb -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls

The expected output should look like:

2020-10-16 02:54:43.177 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-10-16 02:54:47.537 UTC [cli.common] readBlock -> INFO 002 Received block: 0

Download the genesis block of the channel:

docker exec cli peer channel fetch oldest /opt/home/mainchannel.block -c mainchannel -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls

The output should look like:

2020-07-23 03:59:13.501 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-07-23 03:59:13.506 UTC [cli/common] readBlock -> INFO 002 Received block: 0

Join the channel:

docker exec cli peer channel join -b /opt/home/mainchannel.block -o $ORDERER --cafile /opt/home/managedblockchain-tls-chain.pem --tls

The output should look like:

2020-07-23 03:59:21.777 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-07-23 03:59:21.978 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel