nagaraj
nagaraj

Reputation: 947

Hyperledger fabric difference between submit transaction and evaluate transaction

I am using the hyper-ledger fabric network with 2 organisation and chain-code also installed on the network its working. I came across submitTransaction and EvaluateTransaction in fabric node js. what is difference between them, what i observer is.

Upvotes: 4

Views: 2718

Answers (2)

david_k
david_k

Reputation: 5868

The difference between submitTransaction vs evaluateTransaction is that submitTransaction takes the proposal results returned from invoking the smart contract and submits them to the orderer and waits for the transaction to be committed. This means that the proposal results will be ordered and delivered to the peers for validation and committed to the blockchain.

It is irrespective of what the smart contract transaction does, however the general pattern is that submitTransaction is used for transactions that change the world state and evaluateTransaction is used for transactions that only query the world state (or query key history).

However it's perfectly reasonable for example to want to record querying of the world state onto the ledger and so you would use submitTransaction on a smart contract function that doesn't modify the world state in order to do this.

Upvotes: 6

rahul_eth
rahul_eth

Reputation: 132

contract.submittransaction execute the transaction against the chain code that's why it creates the new block. while contract.evaluateTransaction only query the state database that's why don't create the new block.

Upvotes: -1

Related Questions