-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7d9259
commit 2c055ae
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use alloy_network::Ethereum; | ||
use alloy_provider::{Provider, RootProvider}; | ||
use alloy_rpc_client::RpcClient; | ||
use alloy_transport_ipc::IpcConnect; | ||
use eyre::Result; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
// Setup the IPC transport which is consumed by the RPC client | ||
let ipc_path = "/tmp/reth.ipc"; | ||
|
||
// IPC transport | ||
let ipc = IpcConnect::from(ipc_path.to_string()); | ||
|
||
// RPC client using IPC transport | ||
let ipc_client = RpcClient::connect_pubsub(ipc).await?; | ||
|
||
let provider = RootProvider::<Ethereum, _>::new(ipc_client); | ||
|
||
let latest_block = provider.get_block_number().await?; | ||
|
||
println!("Latest block: {}", latest_block); | ||
|
||
Ok(()) | ||
} |