Upgrade a chaincode that is already deployed in a channel to a new version. The upgrade process lets you update the chaincode binaries, change the endorsement policy, or update private data collections.
This topic applies to Fabric V1.4 instances only. For Fabric V2.2, see Manage chaincode (V2.2).
How it works
A chaincode upgrade works similarly to the initial installation: you install a new version on all required peers, then trigger the upgrade from the console.
The chaincode name serves as its identity—it must stay the same across versions. The version number must be different from the previous version.
Prerequisites
Before you begin, ensure that you have:
A running Fabric V1.4 instance on Alibaba Cloud Blockchain as a Service (BaaS)
A chaincode already installed and instantiated in the target channel
Updated chaincode source files (if upgrading the chaincode binaries)
Access to all organizations in the channel
Upgrade a chaincode
Step 1: Prepare the updated chaincode package
Update your chaincode source files locally, then package them. When packaging, set the chaincode name to match the existing deployed version exactly, and use a version number that is different from the previous version.
BaaS supports Go, Node.js, and Java chaincode.
Step 2: Add and install the updated chaincode package
Upload the updated package to the console and install it on all required organizations. For detailed steps, see Install chaincodes in Deploy chaincodes.
Install the chaincode on each organization that participates in the channel.
Verify installation: After installation is complete on all organizations, check the chaincode list. The Actions column should show Upgrade and the Channels column should show Upgradable. If either status is missing for an organization, that organization has not yet installed the new version.
Step 3: Upgrade the chaincode in the channel
In the Actions column, click Upgrade.
In the dialog box, enter the new endorsement policy if you want to change it. Leave the field blank to keep the current policy.
To update the private data collection, click Superior in the dialog box and provide the updated collection definition JSON.
ImportantOnce
nameandblockToLiveare set in a private data collection, they cannot be changed in subsequent upgrades. Only modify other fields.Click Upgrade to confirm.
The upgrade may take several seconds to several minutes, depending on the complexity of the chaincode dependencies.
Verify the upgrade: When the upgrade completes, the chaincode status changes from Upgradable to Running, and the Actions column becomes empty.
What's next
To install a new chaincode in a channel for the first time, see Install chaincodes.
To manage chaincodes on a Fabric V2.2 instance, see Manage chaincode (V2.2).