Hands-On Blockchain with Hyperledger
上QQ阅读APP看书,第一时间看更新

Installing and instantiating chaincode

We now need to install the chaincode on the channel before we initiate it, which will invoke the method Init:

  1. Installing the chaincode: In a new terminal, connect to the CLI container and install the chaincode with the name tw, as follows:
$ docker exec -it cli bash 
$ peer chaincode install -p chaincodedev/chaincode/trade_workflow_v1 -n tw -v 0
  1. Now, instantiate the following chaincode:
$ peer chaincode instantiate -n tw -v 0 -c '{"Args":["init","LumberInc","LumberBank","100000","WoodenToys","ToyBank","200000","UniversalFreight","ForestryDepartment"]}' -C tradechannel 

The CLI-connected terminal now contains a list of log messages of the interaction with the chaincode. The chaincode terminal shows messages from the chaincode method invocation and the network terminal show messages from communication between the peer and the orderer.