Skip to content

MatrixA/chain_index

 
 

Repository files navigation

chain-index

chain-index is a Python package for retrieving blockchain network metadata and common token information from local JSON snapshots.

It supports lookups by chain ID, chain name, alias, and short name, and exposes helpers for native, wrapped-native, and common token access.

Installation

pip install chain-index

Import the package as chain_index:

from chain_index import get_chain_info, get_token_info, get_all_chain_tokens

Quick Start

from chain_index import get_chain_info, get_token_info, get_all_chain_tokens

ethereum = get_chain_info(1)
print(ethereum.name)
print(ethereum.nativeCurrency.symbol)

usdt = get_token_info(1, "USDT")
print(usdt.contract)

tokens = get_all_chain_tokens(1)
print(tokens.get_token("ETH").contract)
print(tokens.get_token("WETH").contract)

API Overview

get_chain_info(chain_identifier)

Returns a ChainInfo model for a chain ID, decimal string, hex string, chain name, alias, or short name.

get_token_info(chain_id, symbol)

Returns a TokenInfo model for a common token on the requested chain.

get_chain_tokens(chain_id)

Returns a dictionary of common token symbols to TokenInfo models for the requested chain.

get_all_chain_tokens(chain_id)

Returns a ChainTokens helper that includes:

  • the native token
  • the wrapped native token when available
  • all configured common tokens

Development

pip install -e ".[dev]"
pytest

Data Sources

This project uses chain metadata derived from chainid.network.

Contributing

Open an issue or submit a pull request in this repository.

Changelog

See CHANGELOG.md for notable changes.

License

This project is licensed under the MIT License. See LICENSE for details.

About

A unified Blockchains' info repo for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%