Crate ethers_providers

source ·
Expand description

§ethers-providers

Clients for interacting with Ethereum nodes.

This crate provides asynchronous Ethereum JSON-RPC compliant clients.

For more information, please refer to the book.

Warning

This library is in the process of being deprecated. See #2667 for more information.

§Websockets

This crate supports for WebSockets via tokio-tungstenite. Please ensure that you have the ws feature enabled if you wish to use WebSockets:

[dependencies]
ethers-providers = { version = "2.0", features = ["ws"] }

§Interprocess Communication (IPC)

This crate supports for Interprocess Communication via Unix sockets and Windows named pipes. Please ensure that you have the ipc feature enabled if you wish to use IPC:

[dependencies]
ethers-providers = { version = "2.0", features = ["ipc"] }

§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 0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e and can be overriden with the ens method on the provider.

§Examples

let provider = Provider::<Http>::try_from("https://eth.llamarpc.com")?;

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

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

Using ENS:

let provider = Provider::<Http>::try_from("https://eth.llamarpc.com")?;

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

/// Lookup ENS field
let url = "https://vitalik.ca".to_string();
let resolved_url = provider.resolve_field(name, "url").await?;
assert_eq!(url, resolved_url);

/// Lookup and resolve ENS avatar
let avatar = "https://ipfs.io/ipfs/QmSP4nq9fnN9dAiCj42ug9Wa79rqmQerZXZch82VqpiH7U/image.gif".to_string();
let resolved_avatar = provider.resolve_avatar(name).await?;
assert_eq!(avatar, resolved_avatar.to_string());

Re-exports§

Modules§

Structs§

  • Holds the inputs to the eth_call rpc method along with the rpc provider. This type is constructed by CallBuilder::new.
  • DevRpcMiddleware
  • 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.
  • Implements RetryPolicy that will retry requests that errored with status code 429 i.e. TOO_MANY_REQUESTS
  • Ipcipc and (Unix or Windows)
    A JSON-RPC Client over Unix IPC.
  • A JSON-RPC 2.0 error
  • Contains the JWT secret and claims parameters.
  • Generates a bearer token from a JWT secret
  • A log query provides streaming access to historical logs via a paginated request. For streaming access to future logs, use Middleware::watch or Middleware::subscribe_logs
  • An implementer of RawCall that maps a function f over the output of the inner future.
  • Mock transport used in test environments.
  • This includes general information about a running node, spanning networking and protocol details.
  • Represents a short summary of information known about a connected peer.
  • 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.
  • RetryClient presents as a wrapper around JsonRpcClient that will retry requests based with an exponential backoff and filtering based on RetryPolicy.
  • Builder for a RetryClient
  • A client containing two clients.
  • 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
  • Wslegacy-ws
    A JSON-RPC Client over Websockets.

Enums§

Constants§

Traits§

Functions§

  • Returns a number in bytes form with padding to fit in 32 bytes.
  • Returns a transaction request for calling the resolver method on the ENS server
  • Create a stream that emits items at a fixed interval. Used for rate control
  • Returns true if the endpoint is local
  • Calls the future if item is None, otherwise returns a futures::ok
  • Returns the ENS namehash as specified in EIP-137
  • Returns the ENS record key hash EIP-634
  • Returns a transaction request for calling
  • Returns the reverse-registrar name of an address.
  • Returns a transaction request for checking interface support

Type Aliases§