🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

web3-block-helper

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-block-helper

help users quickly find blocks by date

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

Web3 Block Helper

help users quickly find blocks by date

Quick start

    // install
    npm install web3-block-helper

    // how to use
    const provider = ethers.providers.JsonRpcProvider(xxx);

    // default block diff timestamp 3s (bsc)
    const blockDiffTimestamp = {
        value: 3,
        unit: 'seconds', // 'seconds' | 'minutes' | 'hours'
    }
    const blockHelper = new BlockHelper(provider, blockDiffTimestamp);

    // default current block number
    await blockHelper.init(/* custom block */)

    // get next 7 days block
    const featBlock = await blockHelper.add(7, 'day');
    console.log(featBlock);

    // get pre 7 days block
    await preBlock = await blockHelper.subtract(7, 'day');
    console.log(preBlock);

API

add

referenc dayjs add

special unit: 'block'

    // will returns dayjs instance
    const dateObj = await blockHelper.add(1, 'block');
    const date = dateObj.format();

subtract

referenc dayjs subtract

special unit: 'block'

    // will returns dayjs instance
    const dateObj = await blockHelper.subtract(1, 'block');
    const date = dateObj.format();

TODO

  • unit test

Keywords

web3

FAQs

Package last updated on 31 Aug 2022

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