@rarcifa/block-time-instance
TypeScript icon, indicating that this package has built-in type declarations

0.2.4 • Public • Published

Block Time Instance

The Block Time Instance is a TypeScript/JavaScript library designed to facilitate easy and efficient interactions with blockchain data, specifically fetching block information based on timestamps. This library provides methods to interact with blockchain endpoints, allowing developers to find blocks closest to given timestamps seamlessly.

npm ES Version Node Version

Features

  • Simple and intuitive API for interacting with blockchain data.
  • Fetch blocks closest to given timestamps.
  • Configurable client instances tailored to your specific blockchain endpoint.

Installation

To install the package, run the following command in your project directory:

npm i @rarcifa/block-time-instance

Usage

Here’s how you can use the Block Time Instance in your project:

Configuring the Instance

import { createBlockTimeClient } from '@rarcifa/block-time-instance';

const blockInstance = createBlockTimeClient({
  endpoint: 'CUSTOM_RPC_ENDPOINT', // evm rpc endpoint
});

Fetching Block by Timestamp

const getBlock = async (timestamp) => {
  try {
    const block = await blockInstance.getBlockFromTimestamp(timestamp);
    console.log('Block:', block);
  } catch (error) {
    console.error('Error fetching block:', error);
  }
};

getBlock(1718196040);

API

BlockTimeInstance Methods

  • getBlockFromTimestamp(timestamp): Fetches the block closest to the given timestamp.

Contributing

Contributions are welcome! If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

Licensing

The code in this project is licensed under MIT license.

Contact

If you have any questions or comments about the library, please feel free to open an issue or a pull request on our GitHub repository.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.2.41latest

Version History

VersionDownloads (Last 7 Days)Published
0.2.41
0.2.31
0.2.21
0.2.11
0.2.01
0.1.91
0.1.81
0.1.71
0.1.61
0.1.51
0.1.41
0.1.31
0.1.21
0.1.11
0.1.01
0.0.91
0.0.81

Package Sidebar

Install

npm i @rarcifa/block-time-instance

Weekly Downloads

0

Version

0.2.4

License

MIT

Unpacked Size

36.8 kB

Total Files

22

Last publish

Collaborators

  • rarcifa