Skip to content

Java chaincode cheatsheet

James Taylor edited this page May 24, 2019 · 6 revisions

Attempting to figure out how to do stuff with Java chaincode on Fabric v2. Don't try this at home!

The following is based on Java chaincode generated using generator-fabric running in a fabric-devenv Vagrant environment.

docker exec -it cli bash
peer lifecycle chaincode package pc0.tar.gz --path /opt/gopath/src/github.com/contracts/java-contract/ --lang java --label pc_0
peer lifecycle chaincode install pc0.tar.gz
export CC_PACKAGE_ID=$(peer lifecycle chaincode queryinstalled 2>&1 | awk -F "[, ]+" '/Label: /{print $3}') && echo $CC_PACKAGE_ID
peer lifecycle chaincode approveformyorg --channelID mychannel --name pc_0 --version 0.0.3 --package-id $CC_PACKAGE_ID --sequence 1 --waitForEvent
peer lifecycle chaincode commit -o orderer.example.com:7050 --channelID mychannel --name pc_0 --version 0.0.3 --sequence 1 --waitForEvent
peer chaincode invoke -o orderer.example.com:7050 --channelID mychannel --name pc_0 -c '{"Args":["arg1","arg2"]}'

See also:

Clone this wiki locally