monosux/ethereum-block-by-date

Generate list of block numbers

Closed this issue · 3 comments

Interesting library! How do I generate a list of block numbers for every single date for the past 3 years?

Screenshot 2021-05-14 at 13 12 47

Hi,

what do you mean? Like first blocks of every day during 3 years? If so, try something like this:

    let blocks = await dater.getEvery(
        'days',
        '2019-09-01T12:00:00Z', // put start date here,
        '2019-09-30T12:00:00Z' // put end date here
    );

It will return you something like this:

[
  {
    date: '2019-09-01T12:00:00Z', // searched date
    block: 8464234, // found block number
    timestamp: 1567339207 // found block timestamp
  },
  {
    date: '2019-09-02T12:00:00Z',
    block: 8470641,
    timestamp: 1567425601
  },
  {
    date: '2019-09-03T12:00:00Z',
    block: 8477057,
    timestamp: 1567512020
  },
  ...
]

Hi, @StayFoolisj I am closing the issue, feel free to contact me if you have more questions.