ethers-rs/ethers-providers
DaniPopes da743fc8b2
ci/test: improve CI jobs and tests (#2189)
* ci: move to scripts directory

* nits

* ci: improve main CI jobs

* fix: install script

* fix

* fix: use curl for windows installation

* fix: wasm typo

* tests: move to single binary

* chore: clippy

* chore: clippy

* chore: clippy

* fix: test command

* fix: quote tests

* update script

* fix: action exclude

* fix: dev deps

* fix: only run wasm in own job

* ci: add aarch64 targets

* test: rm useless test

* ci: update security audit

* ci: add deny CI

* chore: rm unused audit.toml

* chore: update geth.rs

* ci: remove unusable targets

* fix: install script path

* fix: wasm

* improve script

* fix: failing ci

* fix: contract tests

* ci: improve install script

* update middleware tests

* move integration etherscan tests to tests/ dir

* fix: eip2930 access_list field name

* add pendingtransaction must_use

* add random anvil comment

* ci: add miri job

* ci: simplify

* fixci

* Revert "add pendingtransaction must_use"

This reverts commit 770b21b4a3.

* fix: macos script

* fix: use curl in script

* unused ci

* update script

* fix wasm

* rm_miri

* fix: signer test

* fix: wasm ci

* fix: ipc test

* fix: live celo tests

* fix: abi online source test

* fix: windows paths in test

* chore: update serial_test

* ci: run live tests separately

* fix: provider tests

* fix: unused var

* fix: feature

* fix merge

* fix: etherscan key tests

* ci: rm duplicate audit

* fix: split etherscan test ci

* fix: etherscan test

* fix: generate multiple unused ports

* fix: source test

* fix: udeps

* rm unused
2023-02-28 17:26:27 -07:00
..
src ci/test: improve CI jobs and tests (#2189) 2023-02-28 17:26:27 -07:00
tests/it ci/test: improve CI jobs and tests (#2189) 2023-02-28 17:26:27 -07:00
Cargo.toml chore(deps): bump tempfile from 3.3.0 to 3.4.0 (#2200) 2023-02-27 13:03:47 -07:00
README.md chore: replace rpc urls with generic ones (#2199) 2023-02-27 15:16:33 -07:00

README.md

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.

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 = "1.0.2", 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 = "1.0.2", 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

# use ethers_core::types::Address;
# use ethers_providers::{Provider, Http, Middleware, Ws};
# async fn foo() -> Result<(), Box<dyn std::error::Error>> {
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)?);
# Ok(())
# }

Using ENS:

# use ethers_providers::{Provider, Http, Middleware};
# async fn foo() -> Result<(), Box<dyn std::error::Error>> {
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());
# Ok(())
# }