
Eth Chains
Helper module for getting EVM chain info from chainid.network.
Note: This package was initially created by @taylorjdawson. We forked the repository so we can control the release process with an automated script. The original package can be found here.
Installation
yarn add @revoke.cash/chains
Note on versioning
@revoke.cash/chains
uses a weekly automated release script that updates its chain data. This release script takes breaking changes into account, so breaking changes (e.g. renamed chains) are released as a new major version, while non-breaking changes (e.g. new chains) are released as a new minor version.
Usage
Import chains
methods and enums:
import chains, { ChainId, ChainName } from '@revoke.cash/chains'
Easily get most popular chains:
import { chain } from '@revoke.cash/chains'
console.log(chain.ethereum.rinkeby)
console.log(chain.polygon.mumbai)
Chain names and ids via Enums:
console.log(ChainId.EthereumMainnet)
console.log(ChainId.BinanceSmartChainMainnet)
console.log(ChainName.EthereumMainnet)
console.log(ChainName.Rinkeby)
Chain by ID:
chains.getById(ChainId.EthereumMainnet)
chains.getById(1)
Chain by Name:
chains.getByName(ChainName.EthereumMainnet)
chains.getByName('Ethereum Mainnet')
Get all Chains:
const allChains = chains.all()
Typescript Types:
import { Chain, NativeCurrency, Explorer } from '@revoke.cash/chains'
const ethereum: Chain = chains.getById(ChainId.EthereumMainnet)
ethereum.chain