New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eth-block-for-date

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eth-block-for-date

Get Ethereum block number by a given date.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Ethereum Block By Date

Get Ethereum block number by a given date, using viem.

Installation

bun i eth-block-for-date

Usage

import EthDater from 'eth-block-for-date'
import { createPublicClient, http } from 'viem'

const client = createPublicClient({ transport: http('YOUR_RPC_URL') })
const dater = new EthDater(client)

let block = await dater.getDate(
	new Date('2016-07-20T13:20:40Z'), // Date, required.
	true, // Block after, optional. Search for the nearest block before or after the given date. True by default.
	false // Refresh boundaries, optional. Recheck the latest block before request. False by default
)

If the given date is in the future, the script will return the latest block.

License

This project is licensed under the MIT License. Check the License file for more info.

Keywords

FAQs

Package last updated on 11 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc