Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Add fabric /build/bin to your PATH so that you can easily execute the binaries.
Set FABRIC_CFG_PATH to fabric /sampleconfig directory, which contains sample orderer.yaml, peer.yaml, configtx.yaml, and msp for a SampleOrg.

Make sure that the listen addresses in orderer.yaml and peer.yaml do not overlap. By default, Admin.ListenAddress of orderer.yaml and operations.ListenAddress of peer.yaml are set to port 9443. It is recommended to change the port of operations.ListenAddress to 9444.

Open three terminal windows, one each for orderer, peer, and CLI. cd to /fabric directory in each terminal.

...

   peer lifecycle chaincode package marbles.tar.gz --path github.com/hyperledger<PATH_TO_FABRIC_SOURCE>/fabric/integration/chaincode/marbles/cmd --lang golang --label marbles_1

...

   peer lifecycle chaincode approveformyorg -o 127.0.0.1:7050 --channelID mychannel --name marbles --version 1 --package-id $CC_PACKAGE_ID --sequence 1

...

Cleanup data, chaincode containers and images

rm -r rf /var/hyperledger/production/

rm marbles.tar.gz
rm mychannel.*
rm sampleconfig/genesisblock

docker rm -f $(docker ps -aq)

...

configtxgen -channelID mychannel -outputCreateChannelTx mychannel.tx -profile SampleSingleMSPChannel
peer channel create -c mychannel -o 127.0.0.1:7050 -f mychannel.tx
peer channel join -b mychannel.block
peer lifecycle chaincode package marbles.tar.gz --path github.com/hyperledger/fabric/integration/chaincode/marbles/cmd --lang golang --label marbles_1
peer lifecycle chaincode install marbles.tar.gz
CC_PACKAGE_ID=marbles_1:6fdbd197c28600c684cde969c588f9cb4b24acb77d8885e18f03b54ccb3ccb9f274e1e4a1110e74e95973ceb7d0d5fb02347d07d7b70d43c66ea6e8b27f5fc63
peer lifecycle chaincode approveformyorg -o 127.0.0.1:7050 --channelID mychannel --name marbles --version 1 --package-id $CC_PACKAGE_ID --sequence 1
peer lifecycle chaincode commit -o 127.0.0.1:7050 --channelID mychannel --name marbles --version 1 --sequence 1
peer chaincode invoke -o 127.0.0.1:7050 -C mychannel -n marbles -c '{"Args":["initMarble","marble1","blue","35","tom"]}' --waitForEvent
peer chaincode invoke -o 127.0.0.1:7050 -C mychannel -n marbles -c '{"Args":["transferMarble","marble1","jerry"]}' --waitForEvent
peer chaincode query -C mychannel -n marbles -c '{"Args":["readMarble","marble1"]}'

...