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§
Enums§
- Node
Error - 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