fabric-samples/chaincode-docker-devmode/installChaincode.sh
jchen8tw 044e5b78ef new README and new chaincode Lifecycle
Signed-off-by: jchen8tw <11806483+jchen8tw@users.noreply.github.com>
2020-08-13 21:04:51 +08:00

28 lines
1.3 KiB
Bash
Executable file

#!/bin/bash
CHAINCODE_PACKAGE_NAME=$1
CHAINCODE_NAME=$2
SEQUENCE=$3
VERSION=$4
set -e
echo "========= Installing the newest version of chaincode ================"
echo "Chaincode name: $CHAINCODE_NAME"
peer lifecycle chaincode package "chaincode/$CHAINCODE_NAME/go/$CHAINCODE_PACKAGE_NAME" -p "chaincode/$CHAINCODE_NAME/go" --label $CHAINCODE_NAME -l node
peer lifecycle chaincode install "chaincode/$CHAINCODE_NAME/go/$CHAINCODE_PACKAGE_NAME"
CC_PACKAGE_ID=$(peer lifecycle chaincode queryinstalled | tail -n 1 |awk '{print $3}' | tr -d ",")
echo "========= Approving chaincode definition ================="
peer lifecycle chaincode approveformyorg -o orderer:7050 --channelID myc --name $CHAINCODE_NAME --version $VERSION --sequence $SEQUENCE --package-id $CC_PACKAGE_ID
echo "========= Committing chaincode definition ================"
peer lifecycle chaincode commit -o orderer:7050 --channelID myc --name $CHAINCODE_NAME --version $VERSION --sequence $SEQUENCE
echo "========= Finished Committing chaincode definition ======="
echo "Use peer invoke to invoke init transactions:"
echo "peer chaincode invoke -o orderer:7050 -C myc -n $CHAINCODE_NAME -c '{\"Args\":[\"init\",\"a\",\"100\",\"b\",\"200\"]}'"
echo "========= CHAINCODE ID ==================================="
echo $CC_PACKAGE_ID
echo "Use this chaincode id to start chaincode container"