Hyperledger Fabric: invokeChaincode returns [Object object]

0 votes

This is the queried function:

async query(stub, args) {
    let key = args[0]; //key
    let valueAsBytes = await stub.getState(key);
    let valString = valueAsBytes.toString('utf8');
    console.log('Value String: ', valString);
    return shim.success(valString);
}
The payload Buffer decodes to [Object object]
Nov 9, 2018 in Blockchain by slayer
• 29,050 points
183 views

2 answers to this question.

+1 vote
Best answer

Replace 

return shim.success(valString);

with:

return shim.success(Buffer.from(valString));

It should work now

answered Nov 9, 2018 by Omkar
• 67,380 points

selected Feb 7 by Priyaj
+1 vote
do Payload.toString() . it works for me
answered Feb 7 by Sanjeev

Related Questions In Blockchain

+4 votes
2 answers

How do I create a new block in Hyperledger Fabric?

This link might help you: https://github.com/hyperledger/fabric-sample ...READ MORE

answered Oct 11, 2018 in Blockchain by Sahu
473 views
+1 vote
1 answer
+1 vote
1 answer
+1 vote
2 answers
0 votes
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 27,640 points
67 views
+1 vote
1 answer
+15 votes
5 answers
+16 votes
4 answers