ethers-rs/ethers-providers
Georgios Konstantopoulos d7c29cc615
fix: configure rustls & openssl via feature flag (#703)
* chore(etherscan): allow specifying openssl or rustls

* chore(contract): allow specifying openssl or rustls

* chore(solc): allow specifying openssl or rustls

* chore: expose new rustls/openssl features at top level crate

* chore: bump tokio-tungstenite / remove dup rustls version

* chore: bump svm-rs

* fix: feature gate sha2-asm

* ci: remove --all-features from windows tests

* chore: do not enable sha2-asm by default

* fix: do not pull in svm-rs in wasm builds

* chore: use upstream svm again
2021-12-19 16:56:54 +02:00
..
src chore(clippy): make clippy happy (#705) 2021-12-19 06:28:38 +02:00
tests chore: add rustfmt.toml (#537) 2021-10-29 14:29:35 +02:00
Cargo.toml fix: configure rustls & openssl via feature flag (#703) 2021-12-19 16:56:54 +02:00
README.md release: 0.6.0 (#611) 2021-11-23 21:23:12 +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/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)?);
# 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/c60b0bb42f8a4c6481ecd229eddaca27"
# )?;
// 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(())
# }