A Step-by-Step guideline for deploying the smart contract.
Installation and approval of Chaincode
Smart Contracts are officially called as chaincode in Fabric. A peer node can install a smart contract, meaning the smart contract is physically installed to the peer node.
After installation, the chaincode should be approved by all organizations in the channel. Once a smart contract is approved and committed, the smart contract is now active.
The functions in the smart contract can be invoked as transactions. However, only those nodes who have installed the same smart contract can invoke functions (transactions).
Create a Fabric smart contract package using Fabric command "peer"
# Install the packaged smart contractpeerlifecyclechaincodeinstall~/${USER}-chaincode.gz# Verify if the smart contract is installedpeerlifecyclechaincodequeryinstalled
You should see the following output,
Repeat the command in terminal 2.
And also terminal 3,
Approve the installed smart contract on each peer
In terminal 1,
Repeat in terminal 2,
Also in terminal 3
To verify if all peers approve your smart contract. Execute the following command in terminal 1.
You should see the following output
If any organization show false, wait a few seconds and execute the command again until all organization show true
Execute the following command to commit the approved smart contract
Chaincode definition for chaincode 'cyliu-chaincode', version '0', sequence '1' on channel 'cyliu-channel' approval status by org:
greatinsurance: true
police: true
smartinsurance: true