# Parent\_hash in ICP ledger is different than the hash on dashboard

**URL:** <https://forum.dfinity.org/t/parent-hash-in-icp-ledger-is-different-than-the-hash-on-dashboard/25440>\
**Category:** Developers\
**Created:** [December 12, 2023, 8:35am UTC](https://forum.dfinity.org/t/parent-hash-in-icp-ledger-is-different-than-the-hash-on-dashboard/25440 "2023-12-12T08:35:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZenVoich](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/zenvoich/32/5969_2.png) [@ZenVoich](https://forum.dfinity.org/u/ZenVoich)\
**Post date:** [December 12, 2023, 8:35am UTC](https://forum.dfinity.org/t/parent-hash-in-icp-ledger-is-different-than-the-hash-on-dashboard/25440/1 "2023-12-12T08:35:40Z")

</div>

I want to parse ICP transactions from the ledger canister, but I don’t know how to get the correct transaction hash.

For example, 2 consecutive ICP transactions:  
On dashboard:  
7’469’166 [Transaction: 085df7f2cefbf9c80c7ea7bdeb2d7ebfd4d2d8ce2aab487585a6c624e39a5700 - ICP Dashboard](https://dashboard.internetcomputer.org/transaction/085df7f2cefbf9c80c7ea7bdeb2d7ebfd4d2d8ce2aab487585a6c624e39a5700)  
7’469’167 [Transaction: 076062f9ee64777e01c202f72a00658a396bbb1c0069bb82f39a05741d86f9e2 - ICP Dashboard](https://dashboard.internetcomputer.org/transaction/076062f9ee64777e01c202f72a00658a396bbb1c0069bb82f39a05741d86f9e2)

if we get the same txs from icp ledger at [Canister: NNS ICP Ledger - ICP Dashboard](https://dashboard.internetcomputer.org/canister/ryjl3-tyaaa-aaaaa-aaaba-cai)

 ![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/f/fa35ec77328e6263553f1d460e806bbda568542f.png)

 ![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/f/fbbd6dc2d3794a3e652f1bab6dbdd5c35ff9c519.png)

tx 7’469’167 has parent\_hash (which should ref to 7’469’166) `0216316bb82123613f5d64914da3b942ef84a5371f81c2b38758e35c14b9a9ed`

which is different than the hash of tx 7’469’166 on dashboard `085df7f2cefbf9c80c7ea7bdeb2d7ebfd4d2d8ce2aab487585a6c624e39a5700`

 ![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/b/b62f31d9b017c4e9ab6bcd80d35b69810681c38c.png)

---

<div class="post-metadata">

**Author:** ![NikolasHai](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nikolashai/32/11762_2.png) [@NikolasHai](https://forum.dfinity.org/u/NikolasHai)\
**Post date:** [December 12, 2023, 12:54pm UTC](https://forum.dfinity.org/t/parent-hash-in-icp-ledger-is-different-than-the-hash-on-dashboard/25440/2 "2023-12-12T12:54:55Z")

</div>

Hi, I looked at the two blocks you mentioned and I believe there is some confusion around blocks and transaction hashes.

1. A block contains a transaction. A block is unique while a transaction may not be unique.
2. The transaction hash does not have to be unique. There can be multiple transactions in the icp ledger that have the same transaction hash. Uniqueness is only guaranteed when [deduplication](https://github.com/dfinity/ICRC-1/blob/main/standards/ICRC-1/README.md#transaction_deduplication) is set. A block hash contains a unique block index and is therefore always unique.
3. A block hash is not the same as a transaction hash. They hash different objects and are thus never the same.
4. The parent hash in the block object refers to the hash of the previous block in the blockchain that is stored inside the icp ledger. This means that comparing the transaction hashes to a parent hash will never yield the same result.

To sum up: The parent hash is a block hash and should only be compared against another block hash. Block hashes are not the same as transaction hashes. Transaction hashes are not necessarily unique.

I hope this answers your question.

---

<div class="post-metadata">

**Author:** ![ZenVoich](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/zenvoich/32/5969_2.png) [@ZenVoich](https://forum.dfinity.org/u/ZenVoich)\
**Post date:** [December 12, 2023, 2:10pm UTC](https://forum.dfinity.org/t/parent-hash-in-icp-ledger-is-different-than-the-hash-on-dashboard/25440/3 "2023-12-12T14:10:34Z")

</div>

Thanks, I understand the difference now. But it does not resolve my issue, actually. Because I need a transaction hash.

Is it possible to add tx hash to icp ledger canister? New optional field should be backward compatible…  
I think it will be more useful than a block hash.

---

<div class="post-metadata">

**Author:** ![NikolasHai](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nikolashai/32/11762_2.png) [@NikolasHai](https://forum.dfinity.org/u/NikolasHai)\
**Post date:** [December 12, 2023, 2:52pm UTC](https://forum.dfinity.org/t/parent-hash-in-icp-ledger-is-different-than-the-hash-on-dashboard/25440/4 "2023-12-12T14:52:14Z")

</div>

The block hash is important since a blockchain only works a block stores the hash of its previous block. Otherwise, there is no way of varifying a chain of blocks.

There is no plan of adding the transaction hash to the block format right now. You can calculate the hash by serializing the Transaction object and taking a Sha256 hash of it.

The tx hash only gives you a very limited amount of information. The more clear and unique hash is the block hash.

---

<div class="post-metadata">

**Author:** ![ZenVoich](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/zenvoich/32/5969_2.png) [@ZenVoich](https://forum.dfinity.org/u/ZenVoich)\
**Post date:** [December 14, 2023, 3:04am UTC](https://forum.dfinity.org/t/parent-hash-in-icp-ledger-is-different-than-the-hash-on-dashboard/25440/5 "2023-12-14T03:04:49Z")

</div>

> [@NikolasHai](#):
>
> You can calculate the hash by serializing the Transaction object and taking a Sha256 hash of it

How to serialize the transaction in JS?

Is there any example or utility function that calculates the tx hash in JS?

---

<div class="post-metadata">

**Author:** ![ZenVoich](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/zenvoich/32/5969_2.png) [@ZenVoich](https://forum.dfinity.org/u/ZenVoich)\
**Post date:** [December 14, 2023, 3:06am UTC](https://forum.dfinity.org/t/parent-hash-in-icp-ledger-is-different-than-the-hash-on-dashboard/25440/6 "2023-12-14T03:06:48Z")

</div>

> [@NikolasHai](#):
>
> The block hash is important since a blockchain only works a block stores the hash of its previous block. Otherwise, there is no way of varifying a chain of blocks.

Interestingly, this is not implemented for ICRC tokens.

UPD: I see this will be implemented in ICRC-3

---

<div class="post-metadata">

**Author:** ![alexander](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@alexander](https://forum.dfinity.org/u/alexander)\
**Post date:** [January 9, 2024, 8:06pm UTC](https://forum.dfinity.org/t/parent-hash-in-icp-ledger-is-different-than-the-hash-on-dashboard/25440/7 "2024-01-09T20:06:39Z")

</div>

Hello ZenVoich,

I hope this message finds you well. I recently came across your involvement in a project related to ICP (Internet Computer Protocol) transactions and the creation of a JavaScript port. I’m currently working on a similar project and I wanted to inquire if you were successful in creating the JavaScript port for hashing ICP transactions. Any updates or insights you can provide regarding this topic would be greatly appreciated.

Your experience could be of significant value to the community, and I’m keen to hear about your progress. Thank you in advance for your time and assistance.

Best regards,  
Alexander

---

<div class="post-metadata">

**Author:** ![alexander](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@alexander](https://forum.dfinity.org/u/alexander)\
**Post date:** [January 9, 2024, 8:07pm UTC](https://forum.dfinity.org/t/parent-hash-in-icp-ledger-is-different-than-the-hash-on-dashboard/25440/8 "2024-01-09T20:07:50Z")

</div>

Hello NikolasHai,

I hope this message finds you well. I am currently working on a project that involves hashing ICP (Internet Computer Protocol) transactions in Java, and I’m seeking a code example along with sample data to assist with debugging. Specifically, I’d like to understand how to:

1. Encode ICP transaction data in CBOR format.
2. Calculate the SHA-256 hash of the CBOR-encoded data.

To make the debugging process smoother, having an example code snippet along with sample data would be immensely helpful. This will allow me to verify that the transaction hash obtained from my Java implementation matches what’s displayed on the official ICP dashboard and the Rosette client for the same transaction.

Your assistance in providing both code and data for reference is greatly appreciated, and I believe it will not only benefit my project but also be valuable to the community.

Thank you in advance for your time and insights.

Best regards,  
Alexander
