0

I have a chaincode written in node.js and I am trying to read transient values but it's not working properly:

my code:

let secretData = stub.getTransient(); 
let value = secretData.get('privayeKey').toBuffer().toString('utf8')

value is not correct. Some random characters appear.

Narayan Prusty
  • 2,501
  • 3
  • 22
  • 41

1 Answers1

0

Actually it's base64 not utf8. So code is

et secretData = stub.getTransient(); 
let value = secretData.get('privayeKey').toBuffer().toString('base64')
Narayan Prusty
  • 2,501
  • 3
  • 22
  • 41
  • Hi @Narayan. I tried to use your sample code. The original value I used is "this represents a secret data", but when I retrieved the data using the sample code I got the following: "thisrepresentsasecretdat" – A Pantola Aug 02 '19 at 07:50