Crate ethers_providers[][src]

Expand description

Clients for interacting with Ethereum nodes

This crate provides asynchronous Ethereum JSON-RPC compliant clients.

For more documentation on the available calls, refer to the Provider struct.


use ethers_providers::{Provider, Http, Middleware};
use std::convert::TryFrom;

let provider = Provider::<Http>::try_from(

let block = provider.get_block(100u64).await?;
println!("Got block: {}", serde_json::to_string(&block)?);

let code = provider.get_code("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359", None).await?;
println!("Got code: {}", serde_json::to_string(&code)?);


The crate has support for WebSockets via Tokio.

let ws = Ws::connect("ws://localhost:8545").await?;

Ethereum Name Service

The provider may also be used to resolve Ethereum Name Service (ENS) names to addresses (and vice versa). The default ENS address is mainnet and can be overriden by calling the ens method on the provider.

// Resolve ENS name to Address
let name = "vitalik.eth";
let address = provider.resolve_name(name).await?;

// Lookup ENS name given Address
let resolved_name = provider.lookup_address(address).await?;
assert_eq!(name, resolved_name);


Ethereum Name Service support Adapted from


An EscalatingPending is a pending transaction that increases its own gas price over time, by broadcasting successive versions with higher gas prices.

Streams data from an installed filter via eth_getFilterChanges

A low-level JSON-RPC Client over HTTP.

Unix Domain Sockets (IPC) transport.

Mock transport used in test environments.

A pending transaction is a transaction which has been submitted but is not yet mined. await’ing on a pending transaction will resolve to a transaction receipt once the transaction has enough confirmations. The default number of confirmations is 1, but may be adjusted with the confirmations method. If the transaction does not have enough confirmations or is not mined, the future will stay in the pending state.

An abstract provider for interacting with the Ethereum JSON RPC API. Must be instantiated with a data transport which implements the JsonRpcClient trait (e.g. HTTP, Websockets etc.)

A provider that bundles multiple providers and only returns a value to the caller once the quorum has been reached.

Streams data from an installed filter via eth_subscribe

Drains a stream of transaction hashes and yields entire Transaction.

The configuration of a provider for the QuorumProvider

A JSON-RPC Client over Websockets.


Types of filters supported by the JSON-RPC.

Error thrown when sending an HTTP request

Errors for the MockProvider

An error thrown when making a call to the provider

Determines when the provider reached a quorum

Error thrown when sending a WS message


The default polling interval for filters and pending transactions


Trait which must be implemented by data transports to be used with the Ethereum JSON-RPC provider.

A middleware allows customizing requests send and received from an ethereum node.

A transport implementation supporting pub sub subscriptions.

An extension trait for Streams that provides a variety of convenient combinator functions.


Calls the future if item is None, otherwise returns a futures::ok

Type Definitions

A simple gas escalation policy