| Crates.io | cosmos-chain-registry |
| lib.rs | cosmos-chain-registry |
| version | 0.4.0 |
| created_at | 2025-09-24 19:16:22.974906+00 |
| updated_at | 2025-09-25 00:39:44.700003+00 |
| description | A library for interacting with the Cosmos chain registry repository |
| homepage | |
| repository | https://github.com/Cordtus/chain-registry-rust |
| max_upload_size | |
| id | 1853633 |
| size | 78,488 |
A Rust API for interacting with the Cosmos chain registry repository
This crate is a maintained fork of the original chain-registry crate. We created this because:
Option::None for missing chains/paths instead of errorseyre for detailed error contextAdd this to your Cargo.toml:
[dependencies]
cosmos-chain-registry = "0.4.0"
use chain_registry::get::{get_chain, get_assets, get_path, list_chains};
#[tokio::main]
async fn main() -> eyre::Result<()> {
// Get chain information
let chain = get_chain("osmosis").await?.unwrap();
println!("Chain ID: {}", chain.chain_id);
// Get asset information
let assets = get_assets("osmosis").await?.unwrap();
println!("Found {} assets", assets.assets.len());
// Get IBC path information
let path = get_path("osmosis", "cosmoshub").await?.unwrap();
println!("IBC Path: {}-{}", path.chain_1.chain_name, path.chain_2.chain_name);
// List all available chains
let chains = list_chains().await?;
println!("Found {} chains in the registry", chains.len());
Ok(())
}
use chain_registry::{cache::RegistryCache, paths::Tag};
#[tokio::main]
async fn main() -> eyre::Result<()> {
// Build the cache (fetches all IBC paths - may take a moment)
let cache = RegistryCache::try_new().await?;
// Get path between specific chains
let path = cache.get_path("osmosis", "cosmoshub").await?.unwrap();
// Get all paths for a specific chain
let osmosis_paths = cache.get_paths_for_chain("osmosis").await?;
println!("Osmosis has {} IBC connections", osmosis_paths.len());
// Filter paths by channel ID
let channel_paths = cache.get_paths_by_channel("channel-141").await?;
// Filter by custom tags
let dex_paths = cache.get_paths_filtered(Tag::Dex("osmosis".to_string())).await?;
Ok(())
}
The chain registry is unversioned and syntax is unenforced. This library is written to ignore unrecognized or missing JSON fields but it isn't guaranteed to work for all registry items.
chain-registryTo migrate from the original crate:
Cargo.toml: Replace chain-registry with cosmos-chain-registryuse chain_registry::* with use cosmos_chain_registry::*None returns: Methods now return Option<T> for missing data instead of errorsApache-2.0
Originally created by Collin Brittain. This fork is maintained by Cosmos Labs with contributions from the community.