Re: Passing an array as argument to chaincode via Node.js SDK #fabric-questions #fabric-chaincode


Matthew White
 

Hello - 
 
The 'submitTransaction' function takes and array of parameters. In this case the transaction function has a single parameter, but it's an array. 
 
So you need to pass a single element array to 'submitTransaction', with the only element being the  ["v1", "v2"]
 
 
Regards, Matthew.
Matthew B White  IBM Blockchain Solutions Architect
 
Email me at WHITEMAT@...
Find me on StackOverflow, and generally at  calanais.me.uk
 
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: h.hei@...
Sent by: fabric@...
To: fabric@...
Cc:
Subject: [EXTERNAL] [Hyperledger Fabric] Passing an array as argument to chaincode via Node.js SDK #fabric-questions #fabric-chaincode
Date: Thu, Nov 26, 2020 1:04 PM
 
In the chaincode (in Golang) I have the following function:
func (s *SmartContract) f(ctx contractapi.TransactionContextInterface, arr []string) error { /* function details */ }
When I attempt to call this function via the Node.js SDK,
contract.submitTransaction('f', my_array);
where my_array equals ["v1", "v2"]. I get the following error
message=Error managing parameter param0. Conversion error. Value v1,v2 was not passed in expected format []string
What should be the right way to invoke the chaincode function via the SDK?
 
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 fabric@lists.hyperledger.org to automatically receive all group messages.