Getblock through RPC method. I can only see the block hash. But I want a hash for each transaction. What should I do?
-
I have solved it. Thank you for providing methods– AndyCommented May 5, 2022 at 8:07
-
If you have solved the issue, you should post the solution as an answer to this question so that others who have the same issue can also find the solution.– Shawn Tabrizi ♦Commented May 23, 2022 at 16:28
Add a comment
|
1 Answer
The transaction hash is a blake2b-256 of the SCALE-encoded extrinsic data.
This should be consistent, no matter which middleware API is used, the process is the same to get to that point. For instance, in the polkadot-js API, each extrinsic will have a .hash
exposed that does exactly this, i.e. it runs a blake2b-256 over the encoded data as received.
-
-
1The above is not the JS API - so you need to, as explained, get the blake2b-256 of the SCALE-encoded extrinsic data. So call the blake2b in your toolset with the encoded extrinsic, that gives you the hash.– JacoCommented May 5, 2022 at 5:15
-