Skip to main content

ethrpc_rs/
lib.rs

1//! A lightweight async library for making JSON-RPC calls to Ethereum-compatible
2//! nodes. A Rust port of the Go [`ethrpc`](https://github.com/KarpelesLab/ethrpc)
3//! library, built on the [`rsurl`] async HTTP client.
4//!
5//! # Quick start
6//!
7//! ```no_run
8//! use ethrpc_rs::{Rpc, ValueExt};
9//!
10//! # async fn ex() -> Result<(), ethrpc_rs::Error> {
11//! let rpc = Rpc::new("https://cloudflare-eth.com");
12//! let block = rpc.call("eth_blockNumber", vec![]).await?.to_u64()?;
13//! println!("block: {block}");
14//! # Ok(()) }
15//! ```
16//!
17//! All network methods are `async` and must be awaited inside a Tokio runtime.
18
19#![warn(missing_docs)]
20
21#[cfg(feature = "abi")]
22pub mod abi;
23mod api;
24pub mod chains;
25mod decode;
26mod error;
27mod evaluator;
28mod jsonrpc;
29mod rpc;
30
31pub use api::Api;
32pub use decode::ValueExt;
33pub use error::{Error, Result};
34pub use evaluator::{evaluate, RpcList};
35pub use jsonrpc::{ErrorObject, Request, Response, ResponseIntf};
36pub use rpc::{ForwardOptions, ForwardResponse, Handler, OverrideFn, Rpc};