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.
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);
Modules
Ethereum Name Service support Adapted from https://github.com/hhatto/rust-ens/blob/master/src/lib.rs
Structs
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.
Enums
Types of filters supported by the JSON-RPC.
Errors for the MockProvider
An error thrown when making a call to the provider
Determines when the provider reached a quorum
Constants
The default polling interval for filters and pending transactions
Traits
celo
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 Stream
s that provides a variety of convenient
combinator functions.