Skip to content

Commit

Permalink
docs: update example in README (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyodyssey authored Sep 3, 2024
1 parent 3643038 commit 16e4b2c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ A comprehensive breakdown of config options is available in the [config.md](./co
Helios can be imported into any Rust project.

```rust
use std::{str::FromStr, env};
use std::{path::PathBuf, str::FromStr, env};

use helios::{client::ClientBuilder, config::networks::Network, types::BlockTag};
use ethers::{types::Address, utils};
use helios::{client::ClientBuilder, config::networks::Network, types::BlockTag, prelude::*};
use alloy::primitives::{utils, Address};
use eyre::Result;

#[tokio::main]
Expand All @@ -105,14 +105,17 @@ async fn main() -> Result<()> {
.network(Network::MAINNET)
.consensus_rpc("https://www.lightclientdata.org")
.execution_rpc(&untrusted_rpc_url)
.load_external_fallback()
.data_dir(PathBuf::from("/tmp/helios"))
.build()?;

client.start().await?;
client.wait_synced().await;

let head_block_num = client.get_block_number().await?;
let addr = Address::from_str("0x00000000219ab540356cBB839Cbe05303d7705Fa")?;
let block = BlockTag::Latest;
let balance = client.get_balance(&addr, block).await?;
let balance = client.get_balance(addr, block).await?;

println!("synced up to block: {}", head_block_num);
println!("balance of deposit contract: {}", utils::format_ether(balance));
Expand Down

0 comments on commit 16e4b2c

Please sign in to comment.