Suppose I have a very simple block with one transaction whose hash is:


And when I run eth.getBlock I get the following transaction root:


Assuming I have the keccak256 function, how would I verify this root is correct? I.e. how do I build and encode the transactions trie?


You would have to rebuild the trie. It uses the same patricia trie format as seen throughout Ethereum. The best example is in the wiki

Items in the patricia trie come in path->value pairs, and for the transaction trie specifically the path is rlp(transactionIndex). transactionIndexbeing its index within the block it's mined (the ordering decided by a miner). The value is the raw signed transaction.

My js library has functions for both generating the proof and verifying it. It uses the merkle-patricia-tree node module to build the trie.


According to https://github.com/ethereum/wiki/wiki/Patricia-Tree#transactions-trie you should rlpEncode(transactionIndex). So my guess is you'd need to see if that tx hash was present in any of the indexes of the TX trie.

Maybe take a peek at Zac Mitton's https://github.com/zmitton/eth-proof. More specifically https://github.com/zmitton/eth-proof/blob/master/buildProof.js#L147

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.