helios/src/main.rs

38 lines
1.2 KiB
Rust
Raw Normal View History

2022-08-20 17:18:40 +00:00
use std::str::FromStr;
2022-08-21 21:51:11 +00:00
use ethers::prelude::{Address, U256};
use eyre::Result;
2022-08-16 22:59:07 +00:00
2022-08-21 13:13:56 +00:00
use client::Client;
2022-08-19 22:43:58 +00:00
2022-08-21 13:13:56 +00:00
pub mod client;
2022-08-21 16:59:47 +00:00
pub mod common;
2022-08-19 22:43:58 +00:00
pub mod consensus;
2022-08-20 17:18:40 +00:00
pub mod execution;
#[tokio::main]
async fn main() -> Result<()> {
2022-08-21 13:13:56 +00:00
let consensus_rpc = "http://testing.prater.beacon-api.nimbus.team";
let execution_rpc = "https://eth-goerli.g.alchemy.com:443/v2/o_8Qa9kgwDPf9G8sroyQ-uQtyhyWa3ao";
2022-08-19 22:43:58 +00:00
let checkpoint = "0x172128eadf1da46467f4d6a822206698e2d3f957af117dd650954780d680dc99";
2022-08-20 20:33:32 +00:00
2022-08-21 13:13:56 +00:00
let mut client = Client::new(consensus_rpc, execution_rpc, checkpoint).await?;
2022-08-19 22:43:58 +00:00
client.sync().await?;
2022-08-19 00:33:44 +00:00
2022-08-21 13:13:56 +00:00
let header = client.get_header();
println!("synced up to slot: {}", header.slot);
2022-08-20 14:10:28 +00:00
2022-08-21 16:59:47 +00:00
let address = Address::from_str("0x14f9D4aF749609c1438528C0Cce1cC3f6D411c47")?;
2022-08-21 21:51:11 +00:00
let balance = client.get_balance(&address).await?;
let nonce = client.get_nonce(&address).await?;
let code = client.get_code(&address).await?;
let storage_value = client.get_storage_at(&address, U256::from(0)).await?;
2022-08-21 16:59:47 +00:00
2022-08-21 13:13:56 +00:00
println!("balance: {}", balance);
println!("nonce: {}", nonce);
2022-08-21 16:59:47 +00:00
println!("code: 0x{}...", hex::encode(code[..5].to_vec()));
2022-08-21 21:51:11 +00:00
println!("value at slot 0: 0x{:x}", storage_value);
2022-08-20 14:10:28 +00:00
Ok(())
}