"byfn.sh up" - Start Up BYFN Network

Q

How to run "byfn.sh up" to start up the BYFN Network?

✍: FYIcenter.com

A

You can follow this tutorial to run "byfn.sh up" to Start up the BYFN Network.

The "./byfn.sh up" command automatically generates the configuration again, deploys/starts all containers to the Docker Engine, and runs a set of chaincode tests.

$ cd hyperledger-binaries/fabric-samples/first-network
 
$ ./byfn.sh up

Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI 
delay of '3' seconds 
Continue? [Y/n] y

proceeding ...
LOCAL_VERSION=1.4.0
DOCKER_IMAGE_VERSION=2.0.0
=================== WARNING ===================
  Local fabric binaries and docker images are
  out of  sync. This may cause problems.
===============================================

../bin/cryptogen
...

Creating network "net_byfn" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating peer0.org2.example.com ... done
Creating orderer.example.com    ... done
Creating peer0.org1.example.com ... done
Creating peer1.org2.example.com ... done
Creating peer1.org1.example.com ... done
Creating cli                    ... done

 ____    _____      _      ____    _____
/ ___|  |_   _|    / \    |  _ \  |_   _|
\___ \    | |     / _ \   | |_) |   | |
 ___) |   | |    / ___ \  |  _ <    | |
|____/    |_|   /_/   \_\ |_| \_\   |_|

Build your first network (BYFN) end-to-end test

Channel name : mychannel
+ peer channel create -o orderer.example.com:7050 -c mychannel \
   -f ./channel-artifacts/channel.tx --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

Creating channel...
====== Channel 'mychannel' created ======

Having all peers join the channel...
====== peer0.org1 joined channel 'mychannel' ======
====== peer1.org1 joined channel 'mychannel' ======
====== peer0.org2 joined channel 'mychannel' ======
====== peer1.org2 joined channel 'mychannel' ======

Updating anchor peers for org1...
+ peer channel update -o orderer.example.com:7050 -c mychannel \
   -f ./channel-artifacts/Org1MSPanchors.tx --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
====== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' ======

Updating anchor peers for org2...
+ peer channel update -o orderer.example.com:7050 -c mychannel \
   -f ./channel-artifacts/Org2MSPanchors.tx --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
====== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' ======

Installing chaincode on peer0.org1...
+ peer chaincode install -n mycc -v 1.0 -l golang \
   -p github.com/chaincode/chaincode_example02/go/
====== Chaincode is installed on peer0.org1 ======

Install chaincode on peer0.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang \
   -p github.com/chaincode/chaincode_example02/go/
====== Chaincode is installed on peer0.org2 ======

Instantiating chain
code on peer0.org2...
+ peer chaincode instantiate -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 \
   -l golang -v 1.0 -c '{"Args":["init","a","100","b","200"]}' \
   -P 'AND ('\''Org1MSP.peer'\'','\''Org2MSP.peer'\'')'
====== Chaincode is instantiated on peer0.org2 on channel 'mychannel' ======

Querying chaincode on peer0.org1...
====== Querying on peer0.org1 on channel 'mychannel'... ======
Attempting to Query peer0.org1 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x

100
====== Query successful on peer0.org1 on channel 'mychannel' ======

Sending invoke transaction on peer0.org1 peer0.org2...
+ 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 \
   -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
====== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' ======

Installing chaincode on peer1.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang \
   -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
====== Chaincode is installed on peer1.org2 ======

Querying chaincode on peer1.org2...
====== Querying on peer1.org2 on channel 'mychannel'... ======
Attempting to Query peer1.org2 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x

90
====== Query successful on peer1.org2 on channel 'mychannel' ======

====== All GOOD, BYFN execution completed ======
 _____   _   _   ____
| ____| | \ | | |  _ \
|  _|   |  \| | | | | |
| |___  | |\  | | |_| |
|_____| |_| \_| |____/

As you can see, the test went like this:

  • A chaincode was installed on peer0.org1.
  • The same chaincode was installed on peer0.org2.
  • Then chaincode was instantiated with '{"Args":["init","a","100","b","200"]}'. It seems to hold 2 accounts: "a" with $100 and "b" with $200.
  • Then a query was sent to peer0.org1 for account "a" and got "$100" back.
  • Then a transaction was sent to both peer0.org1 and peer0.org2 asking to transfer $10 from "a" to "b".
  • Finally, the same chaincode was installed on peer1.org2.
  • A query was sent to peer1.org2 for account "a" and got "$90" back.

 

"byfn.sh down" - Shut Down BYFN Network

"byfn.sh generate" - Generate BYFN Configuration

BYFN (Build Your First Network)

⇑⇑ Hyperledger Tutorials

2020-05-05, 1089🔥, 0💬