Crate alloy_provider

Source
Expand description

§alloy-provider

Interface with an Ethereum blockchain.

This crate contains the Provider trait, which exposes Ethereum JSON-RPC methods. Providers in alloy are similar to ethers.js providers. They manage an RpcClient and allow other parts of the program to easily make RPC calls.

Unlike an ethers.js Provider, an alloy Provider is network-aware. It is parameterized with a Network from [alloy-networks]. This allows the Provider to expose a consistent interface to the rest of the program, while adjusting request and response types to match the underlying blockchain.

Providers can be composed via stacking. For example, a Provider that tracks the nonce for a given address can be stacked onto a Provider that signs transactions to create a Provider that can send signed transactions with correct nonces.

The ProviderBuilder struct can quickly create a stacked provider, similar to tower::ServiceBuilder.

§Feature flags

  • pubsub - Enable support for subscription methods.
  • ws - Enable WebSocket support. Implicitly enables pubsub.
  • ipc - Enable IPC support. Implicitly enables pubsub.

§Usage

TODO :)

Re-exports§

pub use provider::CallTuple;
pub use provider::SendableTx;
pub use alloy_network as network;
pub use alloy_network::Network;

Modules§

bindings
Multicall bindings
ext
Extended APIs for the provider module.
fillers
Transaction Fillers
layers
Useful layer implementations for the provider. Currently this module contains the AnvilLayer, AnvilProvider and ChainLayer types.
utils
Provider-related utilities.

Structs§

CallItem
A singular call type that is mapped into aggregate, aggregate3, aggregate3Value call structs via the CallInfoTrait trait.
CallItemBuilder
Helper type to build a CallItem
DynProvider
A wrapper struct around a type erased Provider.
Dynamic
Marker for Dynamic Calls i.e where in SolCall type is locked to one specific type and multicall returns a Vec of the corresponding return type instead of a tuple.
Empty
Type indicating that the MulticallBuilder is empty.
EthCall
A builder for an "eth_call" request. This type is returned by the Provider::call method.
EthCallMany
A builder for an "eth_callMany" RPC request.
EthCallManyParams
The parameters for an "eth_callMany" RPC request.
EthCallParams
The parameters for an "eth_call" RPC request.
EthGetBlock
A builder for an "eth_getBlockByHash" request. This type is returned by the Provider::call method.
EthGetBlockParams
The parameters for an eth_getBlockBy{Hash, Number} RPC request.
Failure
A struct representing a failure in a multicall
Identity
An identity layer that does nothing.
IpcConnectipc
An IPC Connection object.
MulticallBuilder
A Multicall3 builder
ParamsWithBlock
Helper struct that houses the params along with the BlockId.
PendingTransaction
Represents a transaction that is yet to be confirmed a specified number of times.
PendingTransactionBuilder
A builder for configuring a pending transaction watcher.
PendingTransactionConfig
Configuration for watching a pending transaction.
ProviderBuilder
A builder for constructing a Provider from various layers.
RootProvider
The root provider manages the RPC client and the heartbeat. It is at the base of every provider stack.
RpcWithBlock
A struct that takes an optional BlockId parameter.
SendableTxErr
Error when converting a [SendableTx].
Stack
A stack of two providers.
WsConnectws
Simple connection details for a websocket connection.

Enums§

MulticallError
Multicall errors.
PendingTransactionError
Errors which may occur when watching a pending transaction.
ProviderCall
The primary future type for the Provider.
WatchTxError
Errors which may occur in heartbeat when watching a transaction.

Constants§

MULTICALL3_ADDRESS
Default address for the Multicall3 contract on most chains. See: https://github.com/mds1/multicall

Traits§

CallInfoTrait
A trait for converting CallItem into relevant call types.
Caller
Trait that helpes convert EthCall into a ProviderCall.
MulticallItem
A trait that is to be implemented by a type that can be distilled to a singular contract call item.
Provider
Ethereum JSON-RPC interface.
ProviderLayer
A layering abstraction in the vein of tower::Layer
WalletProvider
Trait for Providers, Fill stacks, etc, which contain NetworkWallet.

Functions§

builder
Helper function to directly access ProviderBuilder with minimal generics.

Type Aliases§

BoxedFut
Boxed future type used in ProviderCall for non-wasm targets.
FilterPollerBuilder
A task that polls the provider with eth_getFilterChanges, returning a list of R.
HyperProviderDeprecatedhyper
Type alias for a RootProvider using the Http transport and a hyper client.
ReqwestProviderDeprecatedreqwest
Type alias for a RootProvider using the Http transport and a reqwest client.
Result
Result type for multicall operations.