Home

Awesome

chain-registry

<p align="center" width="100%"> <img height="90" src="https://user-images.githubusercontent.com/545047/190171475-b416f99e-2831-4786-9ba3-a7ff4d95b0d3.svg" /> </p> <p align="center" width="100%"> <a href="https://github.com/cosmology-tech/chain-registry/actions/workflows/run-tests.yml"> <img height="20" src="https://github.com/cosmology-tech/chain-registry/actions/workflows/run-tests.yml/badge.svg" /> </a> <a href="https://github.com/cosmology-tech/lib-count"> <img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcosmology-tech%2Flib-count%2Fmain%2Foutput%2Fbadges%2Fproducts%2Fchain-registry%2Ftotal.json" /> </a> <a href="https://github.com/cosmology-tech/lib-count"> <img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcosmology-tech%2Flib-count%2Fmain%2Foutput%2Fbadges%2Fproducts%2Fchain-registry%2Fmonthly.json" /> </a> <br /> <a href="https://github.com/cosmology-tech/chain-registry/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a> <a href="https://www.npmjs.com/package/chain-registry"><img height="20" src="https://img.shields.io/github/package-json/v/cosmology-tech/chain-registry?filename=packages%2Fchain-registry%2Fpackage.json"></a> </p>

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

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';

// create an instance of ChainRegistryClient by passing in the chain names
const client = new ChainRegistryClient({
  chainNames: [
    'osmosis',
    'juno',
    'stargaze'
  ]
});

// chain info, assets and ibc data will be downloaded dynamically by invoking fetchUrls method
await client.fetchUrls();
// get chain data
const chain = client.getChain('osmosis');
// get asset list
const assetList = client.getChainAssetList('osmosis');
// get ibc data
const ibcData = client.getChainIbcData('osmosis');
// get asset list (including ibc assets)
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:

import { assets, chains } from 'chain-registry/mainnet';
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:

import { assets, chain } from 'chain-registry/mainnet/osmosis';
import assets from 'chain-registry/mainnet/osmosis/assets';
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:

import { assets } from 'chain-registry/noncosmos';

Packages

chain-registry

An npm module for the Official chain-registry for the Cosmos βš›οΈ

@chain-registry/client

A Client for chain-registry that allows you to dynamically fetch data.

@chain-registry/types

Types for chain-registry.

@chain-registry/keplr

Keplr integration for the chain-registry returning keplr's ChainInfo type from @chain-registry/types Chain type.

@chain-registry/assets

Asset lists for the Cosmos βš›οΈ

@chain-registry/osmosis

Chain Registry info for Osmosis, including asset lists.

@chain-registry/juno

Chain Registry info for Juno, including asset lists.

@chain-registry/utils

Utility functions for chain-registry.

Developing

Checkout the repository run yarn to initialize the workspace:

# Clone the repo.
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.

make update-cosmos
make update-fixtures

Related

Checkout these related projects:

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.