Lifecycle of Hyperledger Fabric Chaincode Development and Deployment
This article is focused on understanding how Hyperledger Fabric Chaincode development is done and how to easily deploy it whenever you update the chaincode.


In this example, we'll be using the Fabcar Chaincode example provided by Fabric sample. [https://github.com/hyperledger/fabric-samples/tree/master/chaincode/fabcar/go] which uses the basic network [https://github.com/hyperledger/fabric-samples/tree/master/basic-network] as the Hyperledger Fabric network.
Here I assume that you've a good understanding about how Fabric works and how the docker instances for the Fabric network is managed.
Clone the Fabric sample
As the first step, clone the Fabric to your local machine by cloneing it.
git clone https://github.com/hyperledger/fabric-samples
cd fabric-samples
Starting the fabric network
In order to start the fabcar chaincode, go into the fabcar folder and run the startFabric.sh script.
cd fabcard
./startFabric.sh
After this if you want to modify the chaincode and re-deploy you can use the cli container that is running along with the other services.
set -e
# don't rewrite paths for Windows Git Bash users
export MSYS_NO_PATHCONV=1
starttime=$(date +%s)
LANGUAGE=${1:-"golang"}
CC_SRC_PATH=github.com/fabcar/go
if [ "$LANGUAGE": "node" -o "$LANGUAGE": "NODE" ]; then
CC_SRC_PATH=/opt/gopath/src/github.com/fabcar/node
fi
CC_VERSION=1.1
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli peer chaincode install -n fabcar -v $CC_VERSION -p "$CC_SRC_PATH" -l "$LANGUAGE"
docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp" cli peer chaincode upgrade -o orderer.example.com:7050 -C mychannel -n fabcar -l "$LANGUAGE" -v $CC_VERSION -c '{"Args":[""]}' -P "OR ('Org1MSP.member','Org2MSP.member')"The above commands installs a new version of chaincode and upgrades the chaincode by calling the init function. Make sure you change the CC_VERSION everytime you call the script to update chaincode.
Also this will create a new image for each version, so make sure you delete the old images to avoid running out of storage.
Keep reading

How to Build an End-to-End encryption in Hyperledger Fabric
Blockchain goes hand in hand with cryptography, so it is important that we maintain security and privacy of data. Extending the principles of blockchain, learn how to implement end-to-end encryption in smart contracts for the Fabric framework.

Setting up a Hyperledger Fabric Network with Multiple Chaincodes and Multiple Channels
When your Blockchain network grows, it will need much more flexibility. With Hyperledger Fabric, this is introduced with multiple chaincodes and multiple channels.

Simple Steps To Run Hyperledger Fabric Composer Network With Multiple Organization
In my previous article, I wrote about how to run Hyperledger Fabric with multiple peers running in different physical machines. And in this article it's more towards setting up Hyperledger Fabric with multi organization configuration and deploying a composer network.