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: https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html#install-and-define-a-chaincode Nik -----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 documentation https://hyperledger.github.io/fabric-sdk-node/master/tutorial-chaincode-lifecycle.html 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);
|
|