Crate ethers_providers[][src]

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.

Examples

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

let provider = Provider::<Http>::try_from(
    "https://mainnet.infura.io/v3/c60b0bb42f8a4c6481ecd229eddaca27"
)?;

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)?);

Websockets

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);

Structs

FilterWatcher

Streams data from an installed filter via eth_getFilterCahnges

Http

A low-level JSON-RPC Client over HTTP.

MockProvider

Mock transport used in test environments.

PendingTransaction

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.

Provider

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.)

SubscriptionStream

Streams data from an installed filter via eth_subscribe

Ws

A JSON-RPC Client over Websockets.

Enums

FilterKind

Types of filters supported by the JSON-RPC.

MockError

Errors for the MockProvider

ProviderError

An error thrown when making a call to the provider

Constants

DEFAULT_POLL_INTERVAL

The default polling interval for filters and pending transactions

Traits

FromErr
JsonRpcClient

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

Middleware

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

PubsubClient

A transport implementation supporting pub sub subscriptions.

StreamExt

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

Functions

interval