monosux/ethereum-block-by-date

Can't get the block from the date

Closed this issue · 2 comments

0xColm commented

I tried to get the block from the date but it says error like this
image

Source code is following:

const EthDater = require('ethereum-block-by-date');
const dater = new EthDater(web3);
let blockFrom = await dater.getDate('2023-06-21T08:00:00Z');
0xColm commented

Please let me know how to fix this error. Thank you😀

Hi @0xColm,

What is your lib? web3.js or ethers.js? What is your web3 provider?

The error you provided shows that function getBlock(1) of you web3 object returns null. Could you check if your web3 object is returning the correct value for getBlock(1)?