chainlist

Crates.iochainlist
lib.rschainlist
version0.1.3
created_at2025-05-05 21:32:36.37119+00
updated_at2025-05-06 00:52:18.078755+00
descriptionMinimal `no_std` bindings for the Chainlist API.
homepagehttps://github.com/refcell/chainlist
repositoryhttps://github.com/refcell/chainlist
max_upload_size
id1661522
size3,327,066
refcell (refcell)

documentation

README

chainlist • ci license crates.io

Minimal no_std rust bindings for the Chainlist API built in pure Rust.

Getting Started

Add chainlist using cargo add.

cargo add chainlist --features std,online

Or append the chainlist crate to your project.

chainlist = "0.1.3"

Usage

use chainlist::{rpc, Chain, CHAINS};

// Get the RPC Configuration for Ethereum Mainnet.
let mainnet = CHAINS.iter().find(|c| c.chain_id == Some(1)).expect("exists");
assert_eq!(mainnet.name, "Ethereum Mainnet");

// Using the `rpc!` macro.
let mainnet = rpc!(1);
assert_eq!(mainnet.name, "Ethereum Mainnet");

// 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));

Safety

[!Warning]

This is experimental software and is provided on an "as is" and "as available" basis. Expect rapid iteration and use at your own risk.

License

MIT

Acknowledgements

Commit count: 17

cargo fmt