Search code examples
localhosthyperledger-fabrichyperledger-composer

error executing hyperledger fabric code on localhost:3000 (through REST) - transactionId


I have tried executing a sample case of transfer of money between two accounts while referring to this: https://medium.freecodecamp.org/ultimate-end-to-end-tutorial-to-create-an-application-on-blockchain-using-hyperledger-3a83a80cbc71

I have executed all steps, from creating .bna and .card to installing them, starting the network etc. On creating the RESTful API, I am able to see the blockchain on localhost:3000/explore. I am also able to add customers and their linked account details.

However, while performing money transfer, there are two fields that are generated by default : transactionId and timestamp.

screenshot showing 2 additional fields - timestamp and transactionId

It's the transactionId that is creating trouble. It does not allow me to leave it blank, or fill arbitrary values, or remove the field altogether.

error when transactionId field is left blank

update

Even after writing "transactionId" : true or "transactionId" : false, the problem persists.

Another user had encountered a similar problem. They fixed it by making their npm and node.js non-root. In my case, it is already non-root. it is non-root Is it possible that npm and node.js are not installed properly? I had received a few errors during its installation npm errors during installation

Even after removing transactionId and timestamp fields, it doesn't work

error after removing both fields


Solution

  • The transactionID (in the example) ideally should not appear in the Swagger example for the POST operations. That example is generated by the LoopBack to Swagger conversion that is done by LoopBack code (not Composer). You need to remove it (and the timestamp too ideally, as Composer will update its own) in your JSON.

    see Why can I submit a transactionID with a transaction in hyperledger composer REST? for an answer. This loopback/swagger issue was created against loopback - last issue created was https://github.com/strongloop/loopback/issues/3510