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.

Feature: add getBlock and getTransaction to event details

See original GitHub issue

provider.getBlock(blockNum) does not seem to work with newest blocks.

I get this error:

TypeError: Cannot read property 'author' of null
    at checkBlock (D:\walda\node_modules\ethers-providers\provider.js:152:14)
    at D:\walda\node_modules\ethers-providers\provider.js:738:20
    at process._tickCallback (internal/process/next_tick.js:109:7)

There is no problem getting past blocks however. If blockNum is the newest block’s number, then anything less than provider.getBlock(blockNum-1) works

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
szerintedmicommented, Jan 29, 2018

Indeed, it helps thank you! (the bug was in my code, I tried to call this.getBlock on an event returned from getLogs 🥇 )

1reaction
ricmoocommented, Jan 29, 2018

Certain nodes (especially INFURA, where you may be connecting to a different instance on each JSON-RPC call) do not return blocks, receipts or transactions with consistent reads.

Inside a Contract event handler, you can access this which, has a getBlock() method which will wait until the node returns the block.

contract.onfoobar = function() {
    this.getBlock().then(function(block) {
        console.log(block);
    })
}

Does that help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

getBlock
Returns identity and transaction information about a confirmed block in the ledger.
Read more >
gettransaction example for DogeCoin (DOGE) - JSON-RPC
Get detailed information about transaction. Parameters. txid - string. Transactiond id for which the info should be returned. Request. curl ...
Read more >
web3.eth — web3.js 1.0.0 documentation - Read the Docs
add (request) : To add a request object to the batch call. ... Please see the source file for function details. ... using...
Read more >
Provider - ethers
In addition to transaction and filter events, there are several named events. Event Name, Arguments, Description. "block", blockNumber, emitted when a new block ......
Read more >
how can i get details of transactions from any block number ...
Using web3, you can use the function getBlock. Then, you can read the value of "transactions" (an array) from the object received to ......
Read more >

github_iconTop Related Medium Post

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