About transaction_hash and BlockIndex of ICPledger?

How to get valid transaction_hash?
Because after using ICPledger.transfer, the return value is only BlockIndex, without transaction_hash, and at the same time, query_blocks cannot be used to query without transaction_hash.
Because it is found in ICP Explorer https://dashboard.internetcomputer.org/transactions, only transaction_hash can be viewed.

In this way, the transaction can only be browsed by obtaining the transaction_hash in advance. How to obtain the transaction_hash?
Or is it possible to view transactions by BlockIndex?
Thanks!

1 Like

Looking forward to the replies from the big guys

query_blocks method of ICP ledger canister takes block Index and length as argument not tx_hash.

I know, but guiding users to view transactions in ICP Explorer requires knowing the transaction_ hash

1 Like

Looking forward to expert answers

Well not necessarily. You can get it by blockIndex.

Tx details using blockIndex and hashes can be pulled from rosetta api as well. Check these implementation here : https://github.com/dfinityexplorer/dfinityexplorer-dashboard/blob/main/web/src/rosetta/RosettaApi.js
https://github.com/dfinityexplorer/dfinityexplorer-dashboard/blob/630107275f270a22d5ff6bdf0f090a74d0ccaafe/web/src/rosetta/RosettaApi.js#L241

Also I am not an expert or a big guy, so hoping it will help :slight_smile:

1 Like

The blcokchain explorer accepts the BlockIndex but only int he URL, not as a search query.

So to get what you want, simply construct the URL like this:

https://dashboard.internetcomputer.org/transaction/`BlockIndex`

For example: https://dashboard.internetcomputer.org/transaction/10500226

2 Likes

I’ve been asking myself the same question. The truth is that you don’t need the transaction Hash anymore.

However if you do decide to calculate it, this might help :

The SHA256 of this serialised CBOR:
https://cbor.nemo157.com/#type=hex&value=a300a102a4007840653933343436313363393631356138336366313537343864393236356337376237363234343136363637386434613066643564663133313836633634623963340178406238376636303164353038633266653139363764316561636562346538313230356537376532396463343665623936646632303238383831656434633966386302a1001a549411b003a100192710011a654b4fd802a1001b17959aa2607b5b8f

maps to the hash of this transaction : https://dashboard.internetcomputer.org/transaction/e609323577ef35afca168a5b45504549889f4086dba5ef4fae8d9dfb2e9666e0

the process is described here : Ledger canister | Internet Computer