This recipe serves as an extension to the BYFN recipe. We will demonstrate how to add a new organization – Org3 – to the application's channel (mychannel).

Hyperledger Cookbook
By :

This recipe serves as an extension to the BYFN recipe. We will demonstrate how to add a new organization – Org3 – to the application's channel (mychannel).
To run this recipe, you need complete the Reviewing the Hyperledger Fabric architecture and components recipe in this chapter to install Hyperledger Fabric with samples and binaries on the AWS EC2 instance.
Since we need add the new organization, Org3, to BYFN, we will first bring up the BYFN network. Follow these steps:
$ cd ~
$ cd fabric-samples/first-network
$ sudo ./byfn.sh generate
$ sudo ./byfn.sh up
$ cd ~
$ cd fabric-samples/first-network
$ sudo ./eyfn.sh up
The following screenshot confirms org3 is added to mychannel successfully:
We can test this by running a query against Org3 peer0.
$ cd fabric-samples/first-network
$ sudo ./eyfn.sh down
$ sudo ./byfn.sh down
Like what we did in the Building the Fabric network recipe, the eyfn.sh script is a good resource to understand how things work.
We will also look into the command-line steps to see the internal building blocks to add an organization to a channel:
$ cryptogen generate --config=./org3-crypto.yaml
$ configtxgen -printOrg Org3MSP
$ peer channel fetch config config_block.pb -o
orderer.example.com:7050 -c mychannel --tls --cafile
/opt/gopath/src/github.com/hyperledger/fabric/peer/
crypto/ordererOrganizations/example.com/orderers/
orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
$ configtxlator proto_encode --input config.json
--type common.Config
$ configtxlator proto_encode --input modified_config.json
--type common.Config
$ configtxlator compute_update --channel_id mychannel
--original original_config.pb --updated modified_config.pb
$ configtxlator proto_decode --input config_update.pb
--type common.ConfigUpdate
$ peer channel signconfigtx -f org3_update_in_envelope.pb
$ peer channel update -f org3_update_in_envelope.pb -c mychannel -o
orderer.example.com:7050 --tls --cafile
/opt/gopath/src/github.com/hyperledger/fabric/peer/
crypto/ordererOrganizations/example.com/orderers/
orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
$ peer channel fetch 0 mychannel.block -o orderer.example.com:7050
-c mychannel --tls --cafile /opt/gopath/src/github.com/
hyperledger/fabric/peer/crypto/ordererOrganizations/
example.com/orderers/orderer.example.com/
msp/tlscacerts/tlsca.example.com-cert.pem
$ peer channel join
-b mychannel.blockcd fabric-samples/first-network
$ peer chaincode install -n mycc -v 2.0 -l golang -p
github.com/chaincode/chaincode_example02/go/
$ peer chaincode upgrade -o orderer.example.com:7050
--tls true --cafile /opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/ordererOrganizations/example.com/orderers/
orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
-C mychannel -n mycc -v 2.0 -c
'{"Args":["init","a","90","b","210"]}'
-P 'AND ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'',
'\''Org3MSP.peer'\'')'
$ peer chaincode query -C mychannel -n mycc
-c '{"Args":["query","a"]}'
$ peer chaincode invoke -o orderer.example.com:7050 --tls true
--cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/
crypto/ordererOrganizations/example.com/orderers/
orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
-C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051
--tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/peerOrganizations/org1.example.com/peers/
peer0.org1.example.com/tls/ca.crt
--peerAddresses peer0.org2.example.com:7051
--tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/peerOrganizations/org2.example.com/peers/
peer0.org2.example.com/tls/ca.crt
--peerAddresses peer0.org3.example.com:7051
--tlsRootCertFiles/opt/gopath/src/github.com/hyperledger/
fabric/peer/crypto/peerOrganizations/org3.example.com/peers/
peer0.org3.example.com/tls/ca.crt
-c '{"Args":["invoke","a","b","10"]}'
This concludes how to add an organization to an existing network in a channel. We will look at how to use CouchDB to review transactions in the next recipe.
Following all the previous steps will create our first network, which consists of two organizations, two peers per organization, and single Solo ordering service. In this recipe, we showed you how to add a third organization to an application channel with its own peers to an already running first network, and then join it to the new channel.
When you view the log file, you will be able to see details in the following order:
Updating modification policies or altering batch sizes or any other channel configuration can be updated using the same approach but for now we will focus solely on the integration of a new organization.
The following block shows the org3-crypto.yaml section for Org3:
# --------------------------------------------------------------------------
# "PeerOrgs" - Definition of organizations managing peer nodes
# ---------------------------------------------------------------------------
PeerOrgs:
# ---------------------------------------------------------------------------
# Org3
# ---------------------------------------------------------------------------
- Name: Org3
Domain: org3.example.com
EnableNodeOUs: true
Template:
Count: 2
Users:
Count: 1
The following block shows the configtx.yaml section for Org3:
#################################################################################
# Section: Organizations
#
# - This section defines the different organizational identities which will
# be referenced later in the configuration.
#
################################################################################
Organizations:
- &Org3
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org3MSP
# ID to load the MSP definition as
ID: Org3MSP
MSPDir: crypto-config/peerOrganizations/org3.example.com/msp
AnchorPeers:
# AnchorPeers defines the location of peers which can be used for cross org gossip #communication. Note, this value is only
# encoded in the genesis block in the Application section context
- Host: peer0.org3.example.com
Port: 7051
In the next recipe, we will look at how smart contracts work with CouchDB.
Change the font size
Change margin width
Change background colour