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 enablespubsub
.ipc
- Enable IPC support. Implicitly enablespubsub
.
§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
andChainLayer
types. - utils
- Provider-related utilities.
Structs§
- Call
Item - A singular call type that is mapped into aggregate, aggregate3, aggregate3Value call structs via
the
CallInfoTrait
trait. - Call
Item Builder - 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 theProvider::call
method. - EthCall
Many - A builder for an
"eth_callMany"
RPC request. - EthCall
Many Params - The parameters for an
"eth_callMany"
RPC request. - EthCall
Params - The parameters for an
"eth_call"
RPC request. - EthGet
Block - A builder for an
"eth_getBlockByHash"
request. This type is returned by theProvider::call
method. - EthGet
Block Params - 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.
- IpcConnect
ipc
- An IPC Connection object.
- Multicall
Builder - A Multicall3 builder
- Params
With Block - Helper struct that houses the params along with the BlockId.
- Pending
Transaction - Represents a transaction that is yet to be confirmed a specified number of times.
- Pending
Transaction Builder - A builder for configuring a pending transaction watcher.
- Pending
Transaction Config - Configuration for watching a pending transaction.
- Provider
Builder - A builder for constructing a
Provider
from various layers. - Root
Provider - The root provider manages the RPC client and the heartbeat. It is at the base of every provider stack.
- RpcWith
Block - A struct that takes an optional
BlockId
parameter. - Sendable
TxErr - Error when converting a [
SendableTx
]. - Stack
- A stack of two providers.
- WsConnect
ws
- Simple connection details for a websocket connection.
Enums§
- Multicall
Error - Multicall errors.
- Pending
Transaction Error - Errors which may occur when watching a pending transaction.
- Provider
Call - The primary future type for the
Provider
. - Watch
TxError - Errors which may occur in heartbeat when watching a transaction.
Constants§
- MULTICAL
L3_ ADDRESS - Default address for the Multicall3 contract on most chains. See: https://github.com/mds1/multicall
Traits§
- Call
Info Trait - A trait for converting CallItem into relevant call types.
- Caller
- Trait that helpes convert
EthCall
into aProviderCall
. - Multicall
Item - 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.
- Provider
Layer - A layering abstraction in the vein of
tower::Layer
- Wallet
Provider - Trait for Providers, Fill stacks, etc, which contain
NetworkWallet
.
Functions§
- builder
- Helper function to directly access
ProviderBuilder
with minimal generics.
Type Aliases§
- Boxed
Fut - Boxed future type used in
ProviderCall
for non-wasm targets. - Filter
Poller Builder - A task that polls the provider with
eth_getFilterChanges
, returning a list ofR
. - Hyper
Provider Deprecated hyper
- Type alias for a
RootProvider
using theHttp
transport and a hyper client. - Reqwest
Provider Deprecated reqwest
- Type alias for a
RootProvider
using theHttp
transport and a reqwest client. - Result
- Result type for multicall operations.