2

I follow the instruction at https://hyperledger-fabric.readthedocs.io/en/latest/private_data_tutorial.html steps by steps but have error like this "Error: error parsing transient string: invalid character '\n' in string literal - proposal response: " at chain code invoke. Is there anyone have the same issue? Would you please advise how to fix it. Many thanks!

I follow the instruction at https://hyperledger-fabric.readthedocs.io/en/latest/private_data_tutorial.html steps by steps but have error at chain code invoke

The return is "Error: error parsing transient string: invalid character '\n' in string literal - proposal response: "

I issue invoke command bellow: export MARBLE=$(echo -n "{\"name\":\"marble1\",\"color\":\"blue\",\"size\":35,\"owner\":\"tom\",\"price\":99}" | base64) peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["initMarble"]}' --transient "{\"marble\":\"$MARBLE\"}"

export MARBLE=$(echo -n "{\"name\":\"marble1\",\"color\":\"blue\",\"size\":35,\"owner\":\"tom\",\"price\":99}" | base64) peer chaincode invoke -o orderer.example.com:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n marblesp -c '{"Args":["initMarble"]}' --transient "{\"marble\":\"$MARBLE\"}"

expect : [chaincodeCmd] chaincodeInvokeOrQuery->INFO 001 Chaincode invoke successful. result: status:200

Actual result : "Error: error parsing transient string: invalid character '\n' in string literal - proposal response: "

2 Answers 2

2

May i ask which machine are you using? and check if tr -d \n is present while

export MARBLE=$(echo -n "{\"name\":\"marble1\",\"color\":\"blue\",\"size\":35,\"owner\":\"tom\",\"price\":99}" | base64 | tr -d \n)

given

tr command strips off the problematic newline characters that linux base64 command adds.

if the problem still occurs you can refer to How can I replace a newline (\n) using sed? and try

tr -d '\n'

or

tr --delete '\n'

2
  • 1
    Hello Harshit, thanks for your prompt reply. I use Ubuntu 16.04. It works after I add tr -d '\n'. The correct command is: "export MARBLE=$(echo -n "{\"name\":\"marble1\",\"color\":\"blue\",\"size\":35,\"owner\":\"tom\",\"price\":99}" | base64 | tr -d '\n') Thanks!
    – Wang Tony
    Jan 24, 2019 at 6:35
  • That's great :)
    – Harshit
    Jan 24, 2019 at 7:03
1

The Fabric private data tutorial has been updated to indicate the newlines should be stripped away with tr -d \\n like this:

export MARBLE=$(echo -n "{\"name\":\"marble1\",\"color\":\"blue\",\"size\":35,\"owner\":\"tom\",\"price\":99}" | base64 | tr -d \\n)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.