question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get extrinsic details by extrinsic hash

See original GitHub issue

Is there any way to get the transaction details through the transaction hash?

I used blockHash to find the whole block details, and query each of these transactions. Is there a better way?

let block = await api.rpc.chain.getBlock('*****')
        block.block.extrinsics.forEach(ex=>{
            console.log(''ex");
        });

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
SleepingNextcommented, Dec 3, 2020

Hi, @crossle!

First, what do you mean by Block ID?

  1. If you mean Block Height, then you can get the Block Hash first by using: blockHash = await api.rpc.chain.getBlockHash(blockHeight), and then get the block by its hash with: block = await api.rpc.chain.getBlock(blockHash). The transactions (extrinsics) will be inside: block.block.extrinsics.

  2. If you mean Block Hash, then start from the second code I wrote above.

0reactions
polkadot-js-botcommented, Jun 3, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

Read more comments on GitHub >

github_iconTop Results From Across the Web

To get the extrinsic data from the extrinsic Hash
There are a couple ways you could work with that. If you have the extrinsic hash and the block number than you could...
Read more >
Blocks | polkadot{.js}
A block hash refers to the hash over the header, the extrinsic hash refers to the hash of the encoded extrinsic. Since all...
Read more >
Polkadot Protocol Information
The correct way to uniquely identify an extrinsic on a Substrate-based chain is to use the block ID (height or hash) and the...
Read more >
Polkadot Extrinsic — hs-web3 0.8.0.0 documentation
Extrinsic is a piece of data from external world that proposed to be a part of blockchain ... If everything ok then you...
Read more >
Block in sp_runtime::traits - Rust
It has types for `Extrinsic` pieces of information as well as a `Header`. ... You can get an iterator over each of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found