Practical overview
When it fits
Use it when application logic starts with calendar dates or intervals and needs corresponding Ethereum block numbers.
Who it is for
- JavaScript developers building Ethereum analytics or historical-data tools.
- Teams selecting blockchain data by date or recurring time period.
Documented uses
- Resolve the nearest Ethereum block for a particular date.
- Generate block references at regular intervals such as every few hours or weeks.
- Use date-based block selection in an application built with web3.js, ethers.js or viem.
Requirements & limits
- The caller must provide an Ethereum client object; the package is a library rather than a hosted lookup service.
- The README describes support for Ethereum-based mainnet and testnet networks.
- Date parsing uses Moment.js-supported values and timezone handling.
- A lookup before the first block returns block 1, while a future date returns the latest block.
- The repository lists a JavaScript implementation and MIT license.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install and initialize the library
Add the package to a JavaScript project and initialize it with an Ethereum client.
Before you start
- A JavaScript project using npm or yarn.
- A web3.js, ethers.js or viem client connected to an Ethereum-based network.
Steps
Install with the command below or
yarn add ethereum-block-by-date.npm i ethereum-block-by-dateCreate a web3.js object, ethers provider or viem client.
Require
ethereum-block-by-dateand pass the client object tonew EthDater(...).
Expected outcome
An EthDater instance initialized with the supplied Ethereum client.
Guide limitations
- The repository documents initialization; this guide does not cover executing a lookup.
- The examples require an Ethereum client object.
Look up blocks across a time interval
Request block-number results at recurring points between two dates.
Before you start
- An initialized EthDater instance.
- A valid period, start date and end date.
Steps
Call
dater.getEvery(period, startDate, endDate, duration, blockAfter, refreshBoundaries).Choose a period from years, quarters, months, weeks, days, hours or minutes.
Set the optional integer duration and before-or-after preference as needed.
Expected outcome
An array of results containing the requested date, block number and block timestamp for each interval point.
Guide limitations
- If the date is before the first block, the library returns block 1; a future date resolves to the latest block.
- The documented date inputs are values accepted by Moment.js, including strings, milliseconds, Date objects and Moment objects.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 12 October 2026
- Original website title
- monosux/ethereum-block-by-date · Official homepage title · retained in its source language

