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 and make additional changes. The original package can be found here.
yarn add @revoke.cash/chains
@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.
Import chains
methods and enums:
import allChains, { ChainId, ChainName } from '@revoke.cash/chains'
console.log(ChainId.EthereumMainnet) // 1
console.log(ChainId.BinanceSmartChainMainnet) // 56
console.log(ChainName.EthereumMainnet) // "Ethereum Mainnet"
console.log(ChainName.Rinkeby) // "Rinkeby"
getChainById(ChainId.EthereumMainnet) // { name: "Ethereum Mainnet", ..., "infoURL": "https://ethereum.org" }
// Equivalent
getChainById(1)
getChainByName(ChainName.EthereumMainnet) // { name: "Ethereum Mainnet", ..., "infoURL": "https://ethereum.org" }
// Equivalent
getChainByName('Ethereum Mainnet')
const chains = allChains()
// { 1: { name: "Ethereum Mainnet", ..., "infoURL": "https://ethereum.org" }, 2: {...}}
import { Chain, NativeCurrency, Explorer } from '@revoke.cash/chains'
const ethereum: Chain = getChainById(ChainId.EthereumMainnet)
ethereum.chain // 'ETH'