A Multi Organization Application in Hyperledger Fabric



  1. Docker
$ sudo apt install docker.io
$ sudo apt install docker-compose
$ sudo apt-get update
$ sudo apt-get install golang-go
$ export GOPATH=$HOME/go
$ export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
$ source ~/.profile
$ go version
$ go version go1.11 linux/amd64 orderer.multi.org.ledger.com ca.org1.multi.org.ledger.com peer0.org1.multi.org.ledger.com peer1.org1.multi.org.ledger.com peer0.org2.multi.org.ledger.com peer1.org2.multi.org.ledger.com peer0.org3.multi.org.ledger.com peer1.org3.multi.org.ledger.com peer0.org4.multi.org.ledger.com peer1.org4.multi.org.ledger.com

Setup the Blockchain network



./bin/cryptogen generate --config=./crypto-config.yaml
./bin/configtxgen -profile FourOrgsOrdererGenesis -outputBlock ./artifacts/orderer.genesis.block
./bin/configtxgen -profile FourOrgsChannel -outputCreateChannelTx ./artifacts/multiorgledger.channel.tx -channelID multiorgledger
./bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./artifacts/Org1MSPanchors.tx -channelID multiorgledger -asOrg Org1MSP
./bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./artifacts/Org2MSPanchors.tx -channelID multiorgledger -asOrg Org2MSP
./bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./artifacts/Org3MSPanchors.tx -channelID multiorgledger -asOrg Org3MSP
./bin/configtxgen -profile FourOrgsChannel -outputAnchorPeersUpdate ./artifacts/Org4MSPanchors.tx -channelID multiorgledger -asOrg Org4MSP

Docker Compose

docker-compose up -d // the docker-compose.yaml has to be located at same command location

Update the Certificate Keys

Deploy the network

Initialize SDKs for each Organization

Create Channel

Create Anchor Peers

Join Channel

  • After creating the channel, each anchor peer will join the channel and remember Orderer will only create the channel and he can’t join the channel.
  • s.Resmgmtis the resource management client created during Org SDK initialization. So, each organization resource management client will execute the join channel action individually.

Install Chaincode

  • Installing chaincode for the organization will use the same chaincode id & version unless it requires to be different for an organization on specific circumstances.
  • InstallCCRequest will be the same for all organizations but the request will be used by the individual resource management client of the organizations. So, the chaincode will be installed under all the organization independently.

Instantiate Chaincode

  • Chaincode instantiation under a multi org environment will be performed only once. It will be initiated by one organization’s peers and will specify certain endorsement policy considering all the organization network configurations.
  • In this POC, the chaincode policy as mentioned below
policy “OR(‘Org1MSP.member’,’Org2MSP.member’,’Org3MSP.member’,’Org4MSP.member’)”

Affiliate an Organization

  • In Hyperledger Fabric by default “org1 & org2” are affiliated as Certificate Authority organizations.
  • But in the case of other organizations like “org3 & org4", they need to be affiliated using following CA Client API.

Dependency Issue

  1. Hyperledger Fabric-Go-SDK is still in development. If you do dep ensure for each Gopkg.toml in MultiOrgLedger and Chaincode, it will download the govendor folder for each module but it will have some compilation issues while building the project. So I have corrected the errors for both MultiOrgLedger and Chaincode folder.
  2. Please download the vendor folder and add it in your project directory.

Run the application

  1. Compile the application and generate the multiorgledger binary for the application.
  2. Run the multiorgledger binary in the command line, you can see the server is running at PORT 6000.
  3. Now, open your browser and type http://localhost:6000
Users list reading from Hyperledger per Orgnization




Working on various software development projects, [Android, Go, Blockchain, Node.js, MongoDB, JavaScript, Kubernetes, Docker]

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Smart Contracts on Steroids: Solving the Problems Facing Ethereum’s Solidity

HashKey Group Digital Asset Industrial Seminar was held in Hong Kong, focusing on its compliance


DApp Infastructure Design (Part I)

Hot Update: Space SIP is in the Chainlink VRF integrating process

Parcel Bolsters Marketplace with Integration of Mona Spaces

Era Swap Network (ESN) Miner`s Guidance

Headline: Bicameral Ventures invests in Metalyfe; A new blockchain and Web 3.0

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Deeptiman Pattnaik

Deeptiman Pattnaik

Working on various software development projects, [Android, Go, Blockchain, Node.js, MongoDB, JavaScript, Kubernetes, Docker]

More from Medium

SimpleApp — Connect To MongoDB (Part I)

JSON Packages to Go

User Creation And Authentication in Golang Part 1

gorilla/mux 101 (rk-boot): Swagger UI