Illustration of First Network Example in Hyperledger Fabric

  1. create all certificates for the First Network nodes, stored in crypto-config directory
  2. create genesis block and all channel transactions, stored in channel-artifacts directory
  3. use docker compose to bring up the nodes
  4. create channel mychannel and join peers to the channel
  5. designate anchor peers
  6. install chaincode on peers
  7. instantiate chaincode
  8. query from ledger
  9. invoke transaction on First Network and query the ledger

The Network Setup

Here are the nodes of First Network.

Channel Creation

The creation of channel is to create a genesis block, which is block 0. The creation is done on Orderer, and the block 0 is created.

Peers Join the Channel

Peer can join the channel with this mychannel.block file (block 0). Note that in the script the file exists in CLI container, and all commands are issued from CLI container. In real life we need to make sure all peers have the same block 0 file.

peer channel join for all four nodes

Configure Anchor Peers

In First Network, we will designate peer0.org1 and peer0.org2 as the anchor peers.

Block 1 (right side) contains anchor peer information

Chaincode Installation

To use chaincode on a peer, chaincode needs to be first installed on the peer, and then instantiated. In First Network demonstration, chaincode is first installed on peer0.org1 and peer0.org2.

Chaincode Instantiation

In the First Network example, the chaincode is instantiated on peer0.org2. As the chaincode is already installed, we can instantiate the chaincode here.

Query Current State

In the First Network example we query the value of key “a” on peer0.org1.

Invoke to Update Value

Now we invoke a transaction to update the values. According to the chaincode design, the invoke requires an argument list of [“invoke”, “a”, “b”, “10”]. Also this transaction is sent to both Org1 and Org2 (here to peer0.org1 and peer0.org2) per endorsement policy required.

Query Current State

After the ledger is updated, we query the current state on peer1.org2. Note that we do not have the chaincode installed yet in this node.



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