web3_dater

Crates.ioweb3_dater
lib.rsweb3_dater
version0.1.1
sourcesrc
created_at2022-08-31 17:23:01.641149
updated_at2022-08-31 23:56:31.524104
descriptionA simple library to get ethereum block by date using web3
homepage
repositoryhttps://github.com/Syneware/rust-web3-dater
max_upload_size
id655822
size54,776
Christoforos Aslanov (chr314)

documentation

README

Web3 Dater

A simple library to get ethereum block by date using web3

Installation

Add the web3_dater to your project dependencies:

cargo add web3_dater

or

[dependencies]
web3_dater = "0.1.1"

Example

use web3_dater::Web3Dater;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let transport = web3::transports::Http::new("https://rpc.ankr.com/eth").unwrap();
    let web3client = web3::Web3::new(transport);

    // Create a new instance of Web3Dater
    let mut dater = Web3Dater::new(web3client);

    let search_date = DateTime::parse_from_rfc3339("2022-08-31T17:31:00+00:00").unwrap();

    // Get the block by date
    let block = dater.get_block_by_date(search_date, true).await.unwrap();

    println!("{:?}", block);

    Ok(())
}

Docs

Documentation

Support

For support, email support@syneware.com

License

MIT

Commit count: 3

cargo fmt