Skip to content

Instantly share code, notes, and snippets.

@chevdor
Last active April 26, 2018 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chevdor/c4319bd598c0886fba74a195dc783440 to your computer and use it in GitHub Desktop.
Save chevdor/c4319bd598c0886fba74a195dc783440 to your computer and use it in GitHub Desktop.
export CC=mycc
# this installs the Go chaincode
peer chaincode install -n $CC -v 1.0 -p github.com/chaincode/chaincode_example02/go/
# this installs the Node.js chaincode
# make note of the -l flag; we use this to specify the language
peer chaincode install -n $CC -v 1.0 -l node -p /opt/gopath/src/github.com/chaincode/chaincode_example02/node/
# if you did not install your chaincode with a name of mycc, then modify that argument as well
peer chaincode instantiate -o orderer.example.com:7050 --tls --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 $CHANNEL_NAME -n $CC -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
# notice that we must pass the -l flag after the chaincode name to identify the language
peer chaincode instantiate -o orderer.example.com:7050 --tls --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 $CHANNEL_NAME -n $CC -l node -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')"
# start docker logs on the peer
docker logs <peer> --follow
# Query
peer chaincode query -C $CHANNEL_NAME -n $CC -c '{"Args":["query","a"]}'
# Invoke
peer chaincode invoke -o orderer.example.com:7050 --tls --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 $CHANNEL_NAME -n $CC -c '{"Args":["invoke","a","b","10"]}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment