From 16e4b2c76697f8c72c2716ce6341c5dbce63d14b Mon Sep 17 00:00:00 2001 From: Siyuan Han Date: Tue, 3 Sep 2024 21:25:43 +0800 Subject: [PATCH] docs: update example in README (#363) --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d14c0c90..f903a511 100644 --- a/README.md +++ b/README.md @@ -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] @@ -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));