Deploying a blockchain test network

Deploying a blockchain test network

Unless you are behind a corporate firewall with all kinds of restrictions, brining up your first hyperledger fabric network can be quite easy a task.

Softwares needed

Ensure you have the following softwares installed.

  1. GIT - Needed to download HLF sample code from github.
  2. CURL - Install 'Git Extensions' software and with that would come the CURL and GITBASH terminals too. Sometimes the CURL that comes with the host Windows OS might not work.
  3. Docker - Docker compose and docker softwares would be needed. Community edition is enough for experimentation.
  4. Go programming language - for this tutorial I've used Go programming langauage but any of the Java/ Java script implementations can be used too.

Install samples, binaries and docker images

Run the following command in your gitbash terminal. word of caution - roughly 7-8 GB of data would be downloaded for various platform binaries, samples and docker images to be downloaded. Be prepared accordingly when you run this command.

curl -sSL https://bit.ly/2ysbOFE | bash –s
No alt text provided for this image

Start the HLF test network that is provided as part of the standard 'fabric samples' using the following command.

./network.sh up
No alt text provided for this image

  Create channel using the following command.

./network.sh createChannel

Deploy chaincode to the network created

/network.sh deployCC -ccn basic -ccp ../asset-transfer-basic/chaincode-go -ccl go

Now we are ready with the test network UP, channel created and chaincode deployed. Next we'll initialize, query, update the ledger and verify using the following commands.

peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"function":"InitLedger","Args":[]}'​




peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'​




peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n basic --peerAddresses localhost:7051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses localhost:9051 --tlsRootCertFiles ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"function":"TransferAsset","Args":["asset6","Christopher"]}'​




peer chaincode query -C mychannel -n basic -c '{"Args":["ReadAsset","asset6"]}'​

A thorough video tutorial is available here for the interested folks.


To view or add a comment, sign in

More articles by Sivatheja C.

  • Hyperledger Fabric - Chaincode lifecycle

    Hyperledger fabric (HLF) supports multiple technologies in which the chain code can be written. As I write this…

Others also viewed

Explore content categories