Skip to content

Commit

Permalink
feat(providers): ipc transport
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-atreya committed Mar 14, 2024
1 parent c7d9259 commit 2c055ae
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "d5967a
alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "d5967ab", default-features = false }
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "d5967ab", default-features = false }
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "d5967ab", default-features = false }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "d5967ab", default-features = false }
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "d5967ab", features = [
"mock",
] }
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "d5967ab", default-features = false }

alloy-core = { version = "0.6.4", default-features = false, features = ["std"] }
Expand Down
1 change: 1 addition & 0 deletions examples/providers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ alloy-node-bindings.workspace = true
alloy-transport.workspace = true
alloy-transport-http.workspace = true
alloy-transport-ws.workspace = true
alloy-transport-ipc.workspace = true
alloy-network.workspace = true
tokio = { version = "1.36.0", features = ["rt-multi-thread", "macros"] }
eyre = "0.6.12"
Expand Down
25 changes: 25 additions & 0 deletions examples/providers/examples/ipc.rs
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(())
}

0 comments on commit 2c055ae

Please sign in to comment.