monosux/ethereum-block-by-date

Filter Block

Closed this issue · 2 comments

Hi,
Is it possible to filter blocks between two timestamps?
Thanks

Hi @vinodsharmak,

You can request two dates and go through all the blocks between them. Something like this:

    const first_block = await dater.getDate('2022-09-15T06:00:00.000Z');
    const last_block = await dater.getDate('2022-09-15T07:00:00.000Z', false);
    let current_block = first_block.block;
    while (current_block <= last_block.block) {
        // do something with current_block
        current_block++;
    }

Is that what you needed?