1

I have read about the Merkle path of a transaction (path in Block B's Merkle tree from the txn T to the Merkle root) being needed to verify that txn T is included in block B, and I understand that.

My question is (perhaps a naive one):

Is it not enough to check the block number in the object returned by web3.eth.getTransaction(txnHash [, callback]) to verify that a txn is included in a particular block?

2

Yes, if you have a (full) node that has the entire blockchain, then you can look up the block B and see whether a transaction T is in B. Indeed it is sufficient to use web3.eth.getTransaction and check that the block number exists and has enough confirmations.

The Merkle path is very helpful when one does not have the entire blockchain. For example, light clients only have block headers. The light client would need the Merkle path of a transaction T, so that it can verify that T exists in B. In this process, the light client would compute the Merkle root from the path, and then compare this root value against the Merkle root in block header B. If they are equal, the light client has reasonable assurances that T exists in B.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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