Brajesh Singh
Brajesh Singh

Reputation: 653

Does contract.evaluateTransaction(fcn,args) make a transaction during query on endorsing peers?

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.

Upvotes: 2

Views: 846

Answers (1)

david_k
david_k

Reputation: 5868

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.

Upvotes: 3

Related Questions