In the Hyperledger Fabric framework, chaincodes implement smart contracts. Chaincodes can be written in Node.js, Go, or Java. More languages will be supported in the future. This topic describes how to upgrade an existing chaincode in a channel.
If you have not deployed any chaincode in a channel, see Deploy chaincodes. A chaincode package upgrade may modify the source file of the chaincode, the version number, the deployment channel, the endorsement policy, or the configuration of the private data collection. To upgrade a chaincode, perform the following steps:
(Optional) Locally modify the source file of the chaincode, package the source file, and then deploy the chaincode. For more information about how to deploy the chaincode, see the “Upload the chaincode”, “Install the chaincode”, and “Submit the chaincode definition” sections of the Deploy chaincodes topic. After you deploy the chaincode, Upgrade appears in the Actions column, and the status in the Status in Channel column changes to Running.
Click Upgrade in the Actions column.
In the dialog box that appears, view parameters and modify them as needed. Do not modify the name of the chaincode.
Note: When you edit the JSON data in the Privacy Set Configuration parameter, if you set
blockToLive, you cannot modify it anymore during the upgrade.
Click Upgrade. After the chaincode is upgraded, a record for the chaincode appears in the chaincode list of the organization, and the status in the Status in Channel column of the chaincode changes to In consensus.
Confirm and submit the chaincode definition in another organization in the channel. For more information about how to confirm and submit the chaincode definition, see the “Submit the chaincode definition” section of the Deploy chaincodes topic. After the chaincode is upgraded, the record for the new chaincode overwrites that of the original chaincode, the status in the Status in Channel column of the chaincode changes from In consensus to Running, and Upgrade and Display Log appear in the Actions column.
Note: By default, a chaincode can be instantiated only after 50% of the organizations in the channel approve the instantiation.