All Products
Search
Document Center

Upgrade chaincode

Last Updated: Dec 15, 2021

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.

Note

This chapter is applicable to users who purchase an instances of Fabric V2.2. If you purchase an instances of Fabric V1.4, please refer to the Manage chaincode (V1.4)upgrade chaincode.

Procedure

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:

  1. (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.

  2. Click Upgrade in the Actions column.

  3. In the dialog box that appears, view parameters and modify them as needed. Do not modify the name of the chaincode.

    Modify parameters
    Note

    When you edit the JSON data in the Privacy Set Configuration parameter, if you set name or blockToLive, you cannot modify it anymore during the upgrade.

  4. 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.

    Upgrade a chaincode
  5. 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.

    Upgraded
    Note

    By default, a chaincode can be instantiated only after 50% of the organizations in the channel approve the instantiation.