ethers-rs/ethers-providers
dependabot[bot] 903edab7bf
chore(deps): bump tokio-util from 0.6.9 to 0.7.0 (#895)
Bumps [tokio-util](https://github.com/tokio-rs/tokio) from 0.6.9 to 0.7.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/commits)

---
updated-dependencies:
- dependency-name: tokio-util
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-11 13:12:20 +02:00
..
src fix(providers): PendingTransaction::log() missing deref (#886) 2022-02-09 08:48:03 +02:00
tests chore: remove broken celo test 2022-01-24 19:40:46 +02:00
Cargo.toml chore(deps): bump tokio-util from 0.6.9 to 0.7.0 (#895) 2022-02-11 13:12:20 +02:00
README.md Hide Infura API key from docs (#863) 2022-02-04 16:58:53 +02:00

README.md

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;

# async fn foo() -> Result<(), Box<dyn std::error::Error>> {
let provider = Provider::<Http>::try_from(
    "https://mainnet.infura.io/v3/YOUR_API_KEY"
)?;

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)?);
# Ok(())
# }

Websockets

The crate has support for WebSockets via Tokio.

# async fn foo() -> Result<(), Box<dyn std::error::Error>> {
# use ethers_providers::Ws;
let ws = Ws::connect("ws://localhost:8545").await?;
# Ok(())
# }

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.

# use ethers_providers::{Provider, Http, Middleware};
# use std::convert::TryFrom;
# async fn foo() -> Result<(), Box<dyn std::error::Error>> {
# let provider = Provider::<Http>::try_from(
#     "https://mainnet.infura.io/v3/YOUR_API_KEY"
# )?;
// 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);
# Ok(())
# }