Re: New Chaincode Lifecycle and new Programming Model can co exist

Nikhil Gupta

Hey Ross,

The chaincode lifecycle APIs in the Fabric Node SDK were introduced for the Fabric 2.0 Alpha and Beta, but will not be in place for the 2.0 GA. To deploy a chaincode on a channel, you should use the peer CLI. You can find information on how to deploy a chaincode to a channel from the CLI in the first network tutorial:


-----fabric@... wrote: -----
To: Matthew White <WHITEMAT@...>
From: "Ross Tang"
Sent by: fabric@...
Date: 01/06/2020 08:30AM
Cc: fabric@...
Subject: [EXTERNAL] Re: [Hyperledger Fabric] New Chaincode Lifecycle and new Programming Model can co exist

I identified my issues. 

In the step 4: Approve. 

It needs to mychaincode.setPackageId(packageId), before below piece of code

const tx_id = client.newTransactionID();const request = { target: peer1, chaincode: mychaincode, // The chaincode instance fully populated txId: tx_id }

In the step 6: Initialize, the documentation is wrong. (a) is_init flag no longer exists, (b) mychannel.sendTransaction should be corrected to mychannel.sendTransactionProposal

I simply turn off init_required.

const request = { chaincodeId : chaincodeId, fcn: 'Init', args: args, txId: tx_id, is_init: true // must be set to initialization}// starting the container will take longer than the normal request-timeoutconst init_results = await mychannel.sendTransaction(request, 20000);const orderer_request = { proposalResponses: init_results[0], proposal: init_results[1]}// send to the orderer to be committedconst results = await mychannel.sendTransaction(orderer_request);

Also, it needs initialise the channel at top of program. 

Client.setConfigSetting('initialize-with-discovery', true);

On 6 Jan 2020, at 5:32 PM, Matthew White <WHITEMAT@...> wrote:

The Contract API is independent of the lifecycle changes; think of the lifecycle commands really treating your implementation as a black box. 
The error you've mentioned typically will occur when you have a mismatch of the names and identifies in the commands. When I get this I'll copy all my commands to a text file - and then double check all the ids that should match do. 
Hope this helps .
Regards, Matthew.
Matthew B White  IBM Blockchain Solutions Architect
Email me at WHITEMAT@...
Find me on StackOverflow, and generally at
Note: restricted availability for meetings 14:30 to 17:00 UK Tuesday 
IBM United Kingdom Limited, Hursley Park, Winchester, Hampshire, SO21 2JN

"The wrong answers are the ones you go looking for when the right answers stare you in the face"
----- Original message -----
From: "Ross Tang" <tangross@...>
Sent by: fabric@...
To: fabric@...
Subject: [EXTERNAL] [Hyperledger Fabric] New Chaincode Lifecycle and new Programming Model can co exist
Date: Thu, Jan 2, 2020 4:08 PM
I am trying out the Fabric V2 Beta. 
I can successfully commit an approved chaincode, under the new chaincode lifecycle. 
Then, I try to run legacy command `peer chaincode list —installed` or `peer chaincode list —instantiated`. Nothing returns. 
The new command `peer lifecycle chaincode querycommitted` returns normally. 
Also, I try to send transaction via new Contract api, with fabric-contract-api v1.4.4. It returns below error. 
{ Error: make sure the chaincode micc has been successfully defined on channel mychannel and try again: chaincode definition for ‘micc' exists, but chaincode is not installed…. 
In the documentation, it invoke transaction via low level api. 
Can new chaincode lifecycle and new Contract api working together? It seems that the new Contract api can only recognise chaincode deployed in legacy way.
Is my understanding correct?
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Join to automatically receive all group messages.