| Crates.io | graph-networks-registry |
| lib.rs | graph-networks-registry |
| version | 0.7.0 |
| created_at | 2024-11-19 20:39:42.075658+00 |
| updated_at | 2025-07-03 19:36:02.5595+00 |
| description | The Graph Networks Registry types and helpers |
| homepage | |
| repository | https://github.com/pinax-network/graph-networks-libs |
| max_upload_size | |
| id | 1453846 |
| size | 33,403 |
Rust types and helpers for working with The Graph Networks Registry.
Documentation available here.
If you want to always get up-to-date registry, make sure to use the latest version of the crate.
Cargo.toml:
[dependencies]
graph-networks-registry = "0.7.0"
To read the registry from a local file
use graph_networks_registry::NetworksRegistry;
fn main() {
// Parse registry from JSON file
let registry = NetworksRegistry::from_file("TheGraphNetworksRegistry_v0_7_0.json")
.expect("Failed to parse registry");
if let Some(network) = registry.get_network_by_graph_id("mainnet") {
println!("Found mainnet: {:?}", network);
}
// You can also use an alias with get_network_by_graph_id
if let Some(network) = registry.get_network_by_graph_id("eth") {
println!("Found ethereum by alias: {:?}", network);
}
// Find network by CAIP-2 chain ID
if let Some(network) = registry.get_network_by_caip2_id("eip155:1") {
println!("Found ethereum by CAIP-2 ID: {:?}", network);
println!("ID: {}, CAIP-2 ID: {}", network.id, network.caip2_id);
}
}
To fetch the latest compatible registry version from networks-registry.thegraph.com
use graph_networks_registry::NetworksRegistry;
#[tokio::main]
async fn main() {
let registry = NetworksRegistry::from_latest_version()
.await
.expect("Failed to fetch registry");
println!("Loaded {} networks", registry.networks.len());
}
fetch - Enables remote registry fetching functionality using reqwest (enabled by default)If you don't need to fetch the registry from the network, you can turn off the fetch feature in your Cargo.toml:
[dependencies]
graph-networks-registry = { version = "0.7.0", default-features = false }