Crates.io | chainlist |
lib.rs | chainlist |
version | 0.1.3 |
created_at | 2025-05-05 21:32:36.37119+00 |
updated_at | 2025-05-06 00:52:18.078755+00 |
description | Minimal `no_std` bindings for the Chainlist API. |
homepage | https://github.com/refcell/chainlist |
repository | https://github.com/refcell/chainlist |
max_upload_size | |
id | 1661522 |
size | 3,327,066 |
Minimal no_std
rust bindings for the Chainlist API built in pure Rust.
Add chainlist
using cargo add.
cargo add chainlist --features std,online
Or append the chainlist
crate to your project.
chainlist = "0.1.3"
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));
[!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.