Expand description
§chainlist
no_std
bindings to access Chainlist.org RPC config data, programmatically.
This library provides a simple interface to access the RPC configurations available on Chainlist.org.
§Getting Started
Add chainlist
using cargo add.
ⓘ
cargo add chainlist --features=std,online
§Usage
use chainlist::{CHAINS, Chain, rpc};
// Get the RPC configuration for Ethereum Mainnet.
let mainnet: &Chain = CHAINS.iter().find(|chain| chain.chain_id == Some(1)).unwrap();
assert_eq!(mainnet.name, "Ethereum Mainnet");
// Use the `rpc!` macro to get the RPC config for Ethereum Mainnet.
let mainnet_rpc = rpc!(1);
// Get the `Chain` RPC configuration from an alloy "NamedChain".
// Note, this will panic if an RPC configuration doesn't exist
// in the chain list for the given chain id.
let mainnet: Chain = alloy_chains::NamedChain::Mainnet.into();
assert_eq!(mainnet.chain_id, Some(alloy_chains::NamedChain::Mainnet as u64));
§Features
std
: Enables the use of the standard library.online
: Provides a way to fetch the latest RPC configurations from Chainlist.org.
Macros§
- rpc
- The
rpc!
macro is used to instantiate aChain
RPC configuration
Structs§
- CHAINS
- Chain RPC Configurations loaded from a static JSON file.
- Chain
- The Chain object.
- Chain
List - The list of chains.
- Chain
Rpc - The ChainRpc object.
Enums§
- Tracking
- If the RPC is tracked.