DL Fabric Gateway™ User Guide— Section 10
This post is part of the ‘DL Fabric Gateway™ User Guide’ originally published as
This post continues our ongoing discussion regarding upgrading chaincode on DL Fabric Gateway™.
Upgrade Chaincode on DL Fabric Gateway™
Upgrading chaincode enables revisions to be made on older chaincode. This ensures that your chaincode can always be modified or improved.
Goal
Upgrade chaincode on DL Fabric Gateway™ using the fab_upgradeChaincode API:
POST
https://dlfabricnetwork.dltlabs.com/api/1.0/fab_upgradeChaincode
Step 1
Open a Command Line Interface (CLI) of your choice (Terminal, cmd, etc.)
Step 2
Install curl (if not already installed): Download links — Linux/Windows
Step 3
Copy and paste the following API Call into your CLI of choice, and tap “enter” on your keyboard
curl -X POST \
‘https://dlfabricnetwork.dltlabs.com/api/1.0/fab_upgradeChaincode' \
-H ‘Content-Type: application/json’ \
-H ‘Authorization: AUTH_TOKEN_HERE’ \
-d ‘{
“userName” : “your@email.com”,
“chaincodeName” : “YourChaincode”,
“chaincodeVersion”: “v3”,
“chaincodeType” : “golang”,
“args” : [],
“functionName” : “initLedger”,
“channelName”: “yourchannel”
}’
Example:
And will return a success response:
{
“status”: “success”,
“message”: “Successfully upgraded chaincode.”
}
Background Information: Upgrading Chaincode
If we wish to make changes to the chaincode after instantiating it, we can accomplish this by upgrading the chaincode.
The chaincodeVersion component (see Note in “Installing Chaincode on DL Fabric Gateway™”) keeps an index of all compiled versions of the chaincode so that they are unique and can be distinguished from one another.
This property doesn’t change the channel name or code name — it just adds a version each time a chaincode is re-compiled or upgraded. Upgrade requires the repetition of Section 6, with updated chaincode and chaincodeVersion. The upgrade acts as the new instance for the chaincode, so instantiation (Section 7) is not required.
