Skip to main content

Crate ethrpc_rs

Crate ethrpc_rs 

Source
Expand description

A lightweight async library for making JSON-RPC calls to Ethereum-compatible nodes. A Rust port of the Go ethrpc library, built on the rsurl async HTTP client.

§Quick start

use ethrpc_rs::{Rpc, ValueExt};

let rpc = Rpc::new("https://cloudflare-eth.com");
let block = rpc.call("eth_blockNumber", vec![]).await?.to_u64()?;
println!("block: {block}");

All network methods are async and must be awaited inside a Tokio runtime.

Modules§

abi
Minimal Ethereum contract-call helpers (behind the default abi feature).
chains
Static metadata for known EVM-compatible chains.

Structs§

Api
Wraps any Handler and provides convenience methods for common Ethereum RPC calls.
ErrorObject
A JSON-RPC 2.0 error object returned by a server.
ForwardOptions
Options controlling how Rpc::forward builds its response.
ForwardResponse
A response produced by Rpc::forward, ready to be written to whatever HTTP framework the caller uses.
Request
A JSON-RPC 2.0 request object.
Response
A JSON-RPC 2.0 response with a raw JSON result.
ResponseIntf
A JSON-RPC 2.0 response where result is an arbitrary serializable value, used when encoding a locally-produced (overridden) response.
Rpc
A connection to an Ethereum JSON-RPC endpoint over HTTP, with optional basic authentication and local method overrides.
RpcList
A list of Rpc endpoints that implements Handler with failover.

Enums§

Error
Errors returned by RPC operations.

Traits§

Handler
Any backend capable of executing JSON-RPC calls. Implemented by Rpc and RpcList.
ValueExt
Decoding helpers for Ethereum-encoded serde_json::Value results.

Functions§

evaluate
Calls every server with eth_blockNumber, measures response time, and returns a Handler backed by the servers that responded.

Type Aliases§

OverrideFn
A locally-handled RPC method. Receives the positional parameters and returns a JSON value (or an error). Registered with Rpc::set_override.
Result
The crate’s result alias.