Deploying the Smart Contract
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"
In terminal 1,
peer lifecycle chaincode package ~/${USER}-chaincode.gz \
--path ~/fabric_lab_code \
--lang golang \
--label ${USER}-chaincodeInstall your smart contract package on each peer
In terminal 1,
# Install the packaged smart contract
peer lifecycle chaincode install ~/${USER}-chaincode.gz
# Verify if the smart contract is installed
peer lifecycle chaincode queryinstalledYou 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
You should see the following output
Now your smart contract is ready.
Last updated
Was this helpful?