chain-registry
The npm package for the Official Cosmos chain registry
npm install chain-registry
A unified store of chains info, assets, asset lists, and IBC channels for the Cosmos ecosystem. Get everything from token symbols, logos, and IBC denominations for all assets you want to support in your application.
Features
- 🌐 Dynamic Loading via ChainRegistryClient - Utilize the client for dynamic data fetching.
- 📦 Tree-Shaking Support - Optimize your bundles and include only what you need.
- 🔌 Module Compatibility - Supports both CommonJS and ES Module formats, ensuring compatibility with various JavaScript environments and tools.
- 🛠 Utilities for Working with Assets and Chains - Comprehensive tools to manage assets and chains efficiently.
- 🌎 Pre-generated Asset Lists with IBC Denominations for All Chains - Access ready-to-use asset lists across all chains.
- 🔄 Conversions for Keplr, Cosmostation - Easily convert data for use with Keplr and Cosmostation wallets.
Usage
Using the chain-registry
Fetch data from chain-registry
:
import { assets, chains, ibc } from 'chain-registry';
const assetList = assets.find(({chain_name})=>chain_name==='osmosis');
console.log(assetList);
will output:
{
'$schema': '../assetlist.schema.json',
chain_name: 'osmosis',
assets: [
{
description: 'The native token of Osmosis',
denom_units: [Array],
base: 'uosmo',
name: 'Osmosis',
display: 'osmo',
symbol: 'OSMO',
logo_URIs: [Object],
coingecko_id: 'osmosis'
},
{
denom_units: [Array],
base: 'uion',
name: 'Ion',
display: 'ion',
symbol: 'ION',
logo_URIs: [Object],
coingecko_id: 'ion'
}
]
}
Using the @chain-registry/client
for dynamic data
Dynamically fetch data:
import { ChainRegistryClient } from '@chain-registry/client';
const client = new ChainRegistryClient({
chainNames: [
'osmosis',
'juno',
'stargaze'
]
});
await client.fetchUrls();
const chain = client.getChain('osmosis');
const assetList = client.getChainAssetList('osmosis');
const ibcData = client.getChainIbcData('osmosis');
const generatedAssetList = client.getGeneratedAssetLists('osmosis');
Tree-Shaking Imports from chain-registry
Tree-shaking is a modern JavaScript feature that allows for smaller bundle sizes by only including the code that is actually used in your project. The chain-registry
package supports tree-shaking, ensuring that only the specified imports are included in your bundle. Below are examples of how to import different datasets according to your needs.
Importing Data from Mainnets, Testnets, and Devnets
You can directly import assets and chain information based on the network type - mainnet, testnet, or devnet. Here’s how you can import data for each network type:
- Mainnet Chains and Assets
import { assets, chains } from 'chain-registry/mainnet';
- Testnet Chains and Assets
import { assets, chains } from 'chain-registry/testnet';
import { assets, chains } from 'chain-registry/devnet';
Importing Specific Data from a Particular Chain
If you are interested in a specific chain, such as Osmosis on the mainnet, you can import data related to that particular chain only:
- Chains and Assets from a Specific Mainnet Chain (e.g., Osmosis)
import { assets, chain } from 'chain-registry/mainnet/osmosis';
- Only Assets from a Specific Mainnet Chain (e.g., Osmosis)
import assets from 'chain-registry/mainnet/osmosis/assets';
- Only Chain Information from a Specific Mainnet Chain (e.g., Osmosis)
import chain from 'chain-registry/mainnet/osmosis/chain';
Importing Data from Non-Cosmos Chains
To include data from non-Cosmos chains, use the following import:
- Assets from Non-Cosmos Chains
import { assets } from 'chain-registry/noncosmos';
Packages
An npm module for the Official chain-registry
for the Cosmos ⚛️
A Client for chain-registry
that allows you to dynamically fetch data.
Types for chain-registry
.
Keplr integration for the chain-registry returning keplr's ChainInfo
type from @chain-registry/types
Chain
type.
Asset lists for the Cosmos ⚛️
Chain Registry info for Osmosis, including asset lists.
Chain Registry info for Juno, including asset lists.
Utility functions for chain-registry
.
Developing
Checkout the repository run yarn to initialize the workspace:
git clone https://github.com/cosmology-tech/chain-registry
yarn
Building
yarn build
Publishing
First, cd
into the root folder of the project:
cd /your/path/to/chain-registry
Second, update the git submodules:
git submodule update --remote
Third, generate the code:
yarn codegen
Finally, commit and publish the code!
git commit -am "new registry updates"
lerna publish
Updating Submodule Data
Use the following Makefile commands to update the data in the submodules. These commands will ensure that your submodules are synchronized with their respective remote repositories.
- update-cosmos: Updates the submodule to the latest commits of the
cosmos/chain-registry
repository. This should be used to pull the most current production data into your local environment.
make update-cosmos
- update-fixtures: Updates the submodule to the latest commits of the
cosmology-tech/chain-registry-fixtures
repository. Use this for testing purposes to ensure that your tests are running against stable, controlled data sets.
make update-fixtures
Related
Checkout these related projects:
- @cosmology/telescope Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules.
- @cosmwasm/ts-codegen Convert your CosmWasm smart contracts into dev-friendly TypeScript classes.
- chain-registry Everything from token symbols, logos, and IBC denominations for all assets you want to support in your application.
- cosmos-kit Experience the convenience of connecting with a variety of web3 wallets through a single, streamlined interface.
- create-cosmos-app Set up a modern Cosmos app by running one command.
- interchain-ui The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit.
- starship Unified Testing and Development for the Interchain.
Credits
🛠 Built by Cosmology — if you like our tools, please consider delegating to our validator ⚛️
Disclaimer
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.