helios/src/main.rs

38 lines
1.0 KiB
Rust
Raw Normal View History

2022-08-20 17:18:40 +00:00
use std::str::FromStr;
use ethers::prelude::Address;
use eyre::Result;
2022-08-16 22:59:07 +00:00
2022-08-19 22:43:58 +00:00
use consensus::*;
2022-08-20 17:18:40 +00:00
use execution::*;
2022-08-19 22:43:58 +00:00
pub mod consensus;
pub mod consensus_rpc;
2022-08-20 17:18:40 +00:00
pub mod execution;
2022-08-20 14:10:28 +00:00
pub mod execution_rpc;
2022-08-16 22:59:07 +00:00
pub mod utils;
2022-08-19 00:33:44 +00:00
pub mod proof;
#[tokio::main]
async fn main() -> Result<()> {
2022-08-19 22:43:58 +00:00
let rpc = "http://testing.prater.beacon-api.nimbus.team";
let checkpoint = "0x172128eadf1da46467f4d6a822206698e2d3f957af117dd650954780d680dc99";
let mut client = ConsensusClient::new(rpc, checkpoint).await?;
2022-08-20 14:10:28 +00:00
let rpc = "https://eth-goerli.g.alchemy.com:443/v2/o_8Qa9kgwDPf9G8sroyQ-uQtyhyWa3ao";
2022-08-20 17:18:40 +00:00
let execution = ExecutionClient::new(rpc);
2022-08-20 14:10:28 +00:00
2022-08-19 22:43:58 +00:00
client.sync().await?;
2022-08-19 00:33:44 +00:00
2022-08-19 22:43:58 +00:00
let payload = client.get_execution_payload().await?;
2022-08-20 17:18:40 +00:00
println!("verified execution block hash: {}", hex::encode(&payload.block_hash));
2022-08-20 14:10:28 +00:00
2022-08-20 17:18:40 +00:00
let addr = Address::from_str("0x25c4a76E7d118705e7Ea2e9b7d8C59930d8aCD3b")?;
let balance = execution.get_balance(&addr, &payload).await?;
println!("verified account balance: {}", balance);
2022-08-20 14:10:28 +00:00
Ok(())
}