eth-block-timestamp
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

Block by time

Get a block number by its date

NPM version Install Size

Demo -> https://blockbytime.com

Install

npm i eth-block-timestamp

Usage

import Blocks from 'eth-block-timestamp'
 
const blocks = new Blocks(
  (window as any).ethereum || 'https://mainnet.infura.io/v3/{API_KEY}'
)
 
// Get first block info
const { block, timestamp } = await blocks.getDate('first')
 
// Get latest block info
const { block, timestamp } = await blocks.getDate('latest')
 
// Get block info at 03/20/2020
const { block, timestamp } = await blocks.getDate('03/20/2020')
 
// Get block info at 03/20/2020 03:10:00 AM
const { block, timestamp } = await blocks.getDate('03/20/2020 03:10:00 AM')
 
// Get block info at 1586618608 (Unix Timestamp)
const { block, timestamp } = await blocks.getDate('1586618608')

Package Sidebar

Install

npm i eth-block-timestamp

Weekly Downloads

24

Version

0.0.6

License

none

Unpacked Size

18.3 kB

Total Files

12

Last publish

Collaborators

  • imazzara