Skip to main content

Crate alloy_node_bindings

Crate alloy_node_bindings 

Source
Expand description

§alloy-node-bindings

Builders for launching local Anvil, Geth, and Reth child processes.

The node binaries are not bundled: install them on PATH, or select an executable explicitly with the builder’s at or path method. Prefer try_spawn when startup failures should be returned; spawn unwraps the result and therefore panics on any startup error. try_spawn waits until the node’s startup output reports its RPC service ready before returning an instance handle. Readiness output is consumed synchronously, so a live child that emits no newline can delay a configured startup timeout.

use alloy_node_bindings::Anvil;

let anvil = Anvil::new().try_spawn()?;
println!("Anvil is listening at {}", anvil.endpoint());

// Dropping the handle shuts down the child process.
drop(anvil);

Keep the returned instance alive for as long as the node is needed. Anvil and Geth default their HTTP port to zero; use the returned instance’s port or endpoint method to read the OS-assigned port.

Re-exports§

pub use nodes::anvil;
pub use nodes::anvil::Anvil;
pub use nodes::anvil::AnvilInstance;
pub use nodes::geth;
pub use nodes::geth::Geth;
pub use nodes::geth::GethInstance;
pub use nodes::reth;
pub use nodes::reth::Reth;
pub use nodes::reth::RethInstance;

Modules§

nodes
Bindings for various nodes.
utils
Utility functions for the node bindings.

Enums§

NodeError
Errors that can occur when working with the node instance.

Constants§

EIP1559_FEE_ESTIMATION_DEFAULT_PRIORITY_FEE
The default max priority fee per gas, used in case the base fee is within a threshold.
EIP1559_FEE_ESTIMATION_PAST_BLOCKS
The number of blocks from the past for which the fee rewards are fetched for fee estimation.
EIP1559_FEE_ESTIMATION_PRIORITY_FEE_TRIGGER
The threshold for base fee below which we use the default priority fee, and beyond which we estimate an appropriate value for priority fee.
EIP1559_FEE_ESTIMATION_REWARD_PERCENTILE
The default percentile of gas premiums that are fetched for fee estimation.
EIP1559_FEE_ESTIMATION_THRESHOLD_MAX_CHANGE
The threshold max change/difference (in %) at which we will ignore the fee history values under it.
NODE_DIAL_LOOP_TIMEOUT
Timeout for waiting for the node to add a peer.
NODE_STARTUP_TIMEOUT
How long we will wait for the node to indicate that it is ready.
WEI_IN_ETHER
1 Ether = 1e18 Wei == 0x0de0b6b3a7640000 Wei