<blockquote>
  <p>As seen from the example image, we actually could not know that transaction-3 is located under that specific block and leaf-node since a light client only downloads the merkle root</p>
</blockquote>

<p>As a light client, you would be given the branch/path of the tree which corresponds to the transaction you wish to know about, not just the merkle root. By giving you the transaction itself, and the branch of the tree, it lets you verify that the transaction was indeed part of that merkle root. Otherwise there is no way to tell, it is not possible to extra transaction IDs from a merkle root without being given the tree of transactions themselves. A merkle root is just a hash, a 'summary' and commitment to the transactions, it doesn't actually contain any information.</p>

CC BY-SA 3.0
2017-12-06T18:27:20.647Z
As I understand with the merkle root, we should also have/store the 'branch/path' for all the transactions under each block? that will eventually help us to verify the transaction. @MeshCollider♦
alper
CC BY-SA 3.0
2017-12-06T22:12:29.810Z
The merkle tree is always determined by the order of the transactions in the block, you don't need to store it separately unless you want to save a bit of time :)
meshcollider
CC BY-SA 3.0
2017-12-24T12:53:45.330Z
What do you mean by "The merkle tree is always determined by the order of the transactions in the block"? @MeshCollider♦
alper
CC BY-SA 3.0
2017-12-24T12:58:28.120Z
@Alper the order of the transactions is the same as the order of the leaf nodes in the merkle tree
meshcollider
CC BY-SA 3.0
2017-12-24T13:01:33.330Z
Got it. I get lost about. For example: I am a light-client or full-client. There is thousands of TXs on the blockchain. When we want to validate one Tx, should we iterate all blocks on the blockchain or do we know the exact block-number of the each Tx, where we can focus on that block to check Tx's validity? @MeshCollider♦
alper
CC BY-SA 3.0
2017-12-24T13:02:50.573Z
As a light client, you ask full nodes to send you transactions which are relevant and not the rest. BTW please remember to accept my answer if it helped you :)
meshcollider
CC BY-SA 3.0
2017-12-24T13:06:39.620Z
As I understand each block contains its merkle-tree that contain its transactions and all block's merkle-tree is different from each other. So when a full-node provide me the transaction I want; how does the full-node knows the Tx's block number, that could provide me the branch/path of the tree?  @MeshCollider♦
alper
CC BY-SA 3.0
2017-12-24T13:13:47.793Z
@Alper full nodes verify *all* transactions in all blocks so they know what block the transaction is in
meshcollider
CC BY-SA 3.0
2017-12-24T15:47:49.283Z
Sorry for too many questions :( So do full-nodes keep a additional database or hash table the keep record of which transaction located under which block? I didn't ask this question only for light-node perspective but also for the full-client perspective. @MeshCollider♦
alper
CC BY-SA 3.0
2017-12-06T08:54:54.370Z
2017-12-06T08:54:54.370Z
meshcollider
<p>From a previous <a href="https://bitcoin.stackexchange.com/questions/10479/what-is-the-merkle-root">Stack answer</a>. </p>

<p>"We start with just our transaction and its sibling (if it has one) and calculate the hash of those two and verify that it matches the expected value. From that we can ask for the sibling branch of that and calculate the hash of that and verify it. And continue with this process, up the tree. Which only takes ten verifications for 868 transactions. (That's one of the great things about trees, they can hold a lot of values with only a relatively small number of layers.)"</p>

<p>So if we start at TX3, we can work our way up the tree to the merkle root and verify that the transaction took place. </p>

CC BY-SA 3.0
2017-12-05T16:58:30.790Z
I guess you did not get my question. How could we know that Tx-3 located under that specific block?
alper
CC BY-SA 3.0
2017-12-05T16:11:01.620Z
2017-12-05T16:11:01.620Z
DjangoBlockchain
<p><a href="https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/" rel="nofollow noreferrer">https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/</a> :</p>
<blockquote>
<p>If the light client wants to determine the status of a transaction, it
can simply ask for a Merkle proof showing that a particular
transaction is in one of the Merkle trees whose root is in a block
header for the main chain.</p>
</blockquote>
<p><a href="https://i.sstatic.net/mmkSU.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/mmkSU.jpg" alt="enter image description here" /></a></p>
<p>Please note that image is taken from reference <a href="https://i.sstatic.net/mmkSU.jpg" rel="nofollow noreferrer">1</a>.</p>
<blockquote>
<p>Verification of a Merkle path proceed from the leaf node to the Merkle
root.</p>
</blockquote>
<p>As seen from the example image, we actually could not know that transaction-3 is located under that specific block and leaf-node since a light client only downloads the <code>merkle root</code>.</p>
<p><strong>[Q]</strong> How could we determine that a particular transaction in which block's Merkle tree and Merkle tree's which leaf node? In order to determine the status of that transaction should we iterate through all blocks in the blockchain until we find the specific transaction? And when we find its block number, how could be actually determine its leaf node.</p>
<p>Thank you for your valuable time and help.</p>
<p>(1) <a href="https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/" rel="nofollow noreferrer">https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/</a></p>

<blockchain><merkle-tree>
How could we determine that a particular transaction in which block's Merkle tree?
alper
# How could we determine that a particular transaction in which block's Merkle tree?

(Asked by: username_0 on 2017-12-05)

<https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/> :

> If the light client wants to determine the status of a transaction, it
> can simply ask for a Merkle proof showing that a particular
> transaction is in one of the Merkle trees whose root is in a block
> header for the main chain.

[![enter image description here](https://i.sstatic.net/mmkSU.jpg)](https://i.sstatic.net/mmkSU.jpg)

Please note that image is taken from reference [1](https://i.sstatic.net/mmkSU.jpg).

> Verification of a Merkle path proceed from the leaf node to the Merkle
> root.

As seen from the example image, we actually could not know that transaction-3 is located under that specific block and leaf-node since a light client only downloads the `merkle root`.

**[Q]** How could we determine that a particular transaction in which block's Merkle tree and Merkle tree's which leaf node? In order to determine the status of that transaction should we iterate through all blocks in the blockchain until we find the specific transaction? And when we find its block number, how could be actually determine its leaf node.

Thank you for your valuable time and help.

(1) <https://blog.ethereum.org/2015/11/15/merkling-in-ethereum/>

**Tags:** blockchain, merkle-tree


---

## 2 answers

### Answer by username_1 on 2017-12-06. Score: 1 | Accepted answer

> As seen from the example image, we actually could not know that transaction-3 is located under that specific block and leaf-node since a light client only downloads the merkle root

As a light client, you would be given the branch/path of the tree which corresponds to the transaction you wish to know about, not just the merkle root. By giving you the transaction itself, and the branch of the tree, it lets you verify that the transaction was indeed part of that merkle root. Otherwise there is no way to tell, it is not possible to extra transaction IDs from a merkle root without being given the tree of transactions themselves. A merkle root is just a hash, a 'summary' and commitment to the transactions, it doesn't actually contain any information.

> **Comments:**
> **username_0**: As I understand with the merkle root, we should also have/store the 'branch/path' for all the transactions under each block? that will eventually help us to verify the transaction. @MeshCollider♦  
> **username_1**: The merkle tree is always determined by the order of the transactions in the block, you don't need to store it separately unless you want to save a bit of time :)  
> **username_0**: What do you mean by "The merkle tree is always determined by the order of the transactions in the block"? @MeshCollider♦  
> **username_1**: @username_0 the order of the transactions is the same as the order of the leaf nodes in the merkle tree  
> **username_0**: Got it. I get lost about. For example: I am a light-client or full-client. There is thousands of TXs on the blockchain. When we want to validate one Tx, should we iterate all blocks on the blockchain or do we know the exact block-number of the each Tx, where we can focus on that block to check Tx's validity? @MeshCollider♦  
> **username_1**: As a light client, you ask full nodes to send you transactions which are relevant and not the rest. BTW please remember to accept my answer if it helped you :)  
> **username_0**: As I understand each block contains its merkle-tree that contain its transactions and all block's merkle-tree is different from each other. So when a full-node provide me the transaction I want; how does the full-node knows the Tx's block number, that could provide me the branch/path of the tree?  @MeshCollider♦  
> **username_1**: @username_0 full nodes verify *all* transactions in all blocks so they know what block the transaction is in  
> **username_0**: Sorry for too many questions :( So do full-nodes keep a additional database or hash table the keep record of which transaction located under which block? I didn't ask this question only for light-node perspective but also for the full-client perspective. @MeshCollider♦  

---

### Answer by username_2 on 2017-12-05. Score: 0

From a previous [Stack answer](https://bitcoin.stackexchange.com/questions/10479/what-is-the-merkle-root).

"We start with just our transaction and its sibling (if it has one) and calculate the hash of those two and verify that it matches the expected value. From that we can ask for the sibling branch of that and calculate the hash of that and verify it. And continue with this process, up the tree. Which only takes ten verifications for 868 transactions. (That's one of the great things about trees, they can hold a lot of values with only a relatively small number of layers.)"

So if we start at TX3, we can work our way up the tree to the merkle root and verify that the transaction took place.

> **Comments:**
> **username_0**: I guess you did not get my question. How could we know that Tx-3 located under that specific block?  

---

