2

I am using hyperledger fabric 1.4, and facing an issue, while querying using the node sdk await contract.evaluateTransaction(fcn,args), I am getting this error : -

Errors: ["2 UNKNOWN: invalid txid. got [00ce5ece85f645e6781515b10c9325e4f6fa743bb49042c940900db4359a42d1], expected [66e0e0c782c4a17b5815255ce5685ceb088f0dd47639950c2462144318197004]"], stack=FabricError

I am just confused that does it create a new transaction ? I read it here https://fabric-sdk-node.github.io/release-1.4/module-fabric-network.Contract.html#evaluateTransaction__anchor please have a look, as it is not clear to me.

Brajesh Singh
  • 635
  • 1
  • 5
  • 15

1 Answers1

3

The differences between evaluateTransaction and submitTransaction is that submitTransaction sends requests to the appropriate peers (appropriate being based on endorsement policy if service discovery is used, or all peers in the channel if service discovery is not used) and collects the transaction proposal responses it receives back from the requests to the peers and submits those to the orderer to be ordered and sent to the peers for validation and committed to the blockchain.

EvaluateTransaction will send a request to a single appropriate peer (ie one from your organisation) and doesn't send anything to the orderer but just returns the response to the application making the invocation. You use evaluate transaction to perform query type of requests usually.

Looking at the error message, it would appear you are using an incorrect transaction id when you call evaluateTransaction. Unless you really know what you are doing, it's better to let evaluateTransaction generate the transaction id for you on your behalf.

david_k
  • 5,843
  • 2
  • 9
  • 16
  • Hi, Thanks for your answer, my problem is that, I have made the transactions using submitTransaction (discovery- true), meanwhile we use evaluateTransaction to query the results and based on that result I do another transaction. But problems occurs when executing the evaluateTransaction we get its not in proper state, we throw error and process further to do transation, this time I get ["2 UNKNOWN: invalid txid. got [00ce5ece85f645e6781515b10c9325e4f6fa743bb49042c940900db4359a42d1], expected [66e0e0c782c4a17b5815255ce5685ceb088f0dd47639950c2462144318197004]"]. – Brajesh Singh Jul 03 '19 at 07:35
  • I guess evaluateTransaction has made a transaction, which causing this error, how to resolve this, any help would be appreciated. – Brajesh Singh Jul 03 '19 at 07:37
  • 1
    The only way I can guess (without seeing your code) is that you are passing a transaction id to the evaluateTransaction call. If you are doing that, then the fix would be to remove passing a transaction id in. You don't evaluate transactions based on a previous transaction id. An evaluateTransaction is a completely new transaction proposal – david_k Jul 03 '19 at 07:40