ethers 0.6.2

Complete Ethereum library and wallet implementation in Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use ethers::{prelude::*, utils::Ganache};
use std::time::Duration;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let ganache = Ganache::new().block_time(1u64).spawn();
    let ws = Ws::connect(ganache.ws_endpoint()).await?;
    let provider = Provider::new(ws).interval(Duration::from_millis(2000));
    let mut stream = provider.watch_blocks().await?.take(5);
    while let Some(block) = stream.next().await {
        dbg!(block);
    }

    Ok(())
}