Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Chains – Uniswap SDK
Skip to content

Chains

Chain IDs and native currency configurations for supported networks.

Import

import {
  ChainId,
  SUPPORTED_CHAINS,
  NativeCurrencyName,
  type SupportedChainsType,
} from '@uniswap/sdk-core-next'

ChainId Enum

enum ChainId {
  // Mainnets
  MAINNET = 1,
  OPTIMISM = 10,
  ARBITRUM_ONE = 42161,
  POLYGON = 137,
  BNB = 56,
  AVALANCHE = 43114,
  BASE = 8453,
  ZORA = 7777777,
  BLAST = 81457,
  ZKSYNC = 324,
  WORLDCHAIN = 480,
  UNICHAIN = 130,
  CELO = 42220,
  GNOSIS = 100,
  MOONBEAM = 1284,
  ROOTSTOCK = 30,
  SONEIUM = 1868,
  MONAD = 143,
  XLAYER = 196,
 
  // Testnets
  GOERLI = 5,
  SEPOLIA = 11155111,
  OPTIMISM_GOERLI = 420,
  OPTIMISM_SEPOLIA = 11155420,
  ARBITRUM_GOERLI = 421613,
  ARBITRUM_SEPOLIA = 421614,
  POLYGON_MUMBAI = 80001,
  BASE_GOERLI = 84531,
  BASE_SEPOLIA = 84532,
  ZORA_SEPOLIA = 999999999,
  CELO_ALFAJORES = 44787,
  UNICHAIN_SEPOLIA = 1301,
  MONAD_TESTNET = 10143,
}

Usage

import { ChainId, Ether, Token } from '@uniswap/sdk-core-next'
 
// Create ETH for a specific chain
const eth = Ether.onChain(ChainId.MAINNET)
 
// Create a token on Arbitrum
const ARB = new Token(
  ChainId.ARBITRUM_ONE,
  '0x912CE59144191C1204E64559FE8253a0e49E6548',
  18,
  'ARB',
  'Arbitrum'
)
 
// Check chain support
function isSupported(chainId: number): boolean {
  return SUPPORTED_CHAINS.includes(chainId as SupportedChainsType)
}

SUPPORTED_CHAINS

Array of all supported chain IDs:

const SUPPORTED_CHAINS = [
  ChainId.MAINNET,
  ChainId.OPTIMISM,
  ChainId.ARBITRUM_ONE,
  ChainId.POLYGON,
  ChainId.BNB,
  ChainId.AVALANCHE,
  ChainId.BASE,
  ChainId.ZORA,
  ChainId.BLAST,
  ChainId.ZKSYNC,
  ChainId.WORLDCHAIN,
  ChainId.UNICHAIN,
  ChainId.CELO,
  ChainId.ROOTSTOCK,
  ChainId.SONEIUM,
  ChainId.MONAD,
  ChainId.XLAYER,
  // ... testnets
] as const

NativeCurrencyName

Names for native currencies on different chains:

enum NativeCurrencyName {
  ETHER = 'ETH',
  MATIC = 'MATIC',
  CELO = 'CELO',
  GNOSIS = 'XDAI',
  MOONBEAM = 'GLMR',
  BNB = 'BNB',
  AVAX = 'AVAX',
  ROOTSTOCK = 'RBTC',
}

Chain Details

ChainIDNativeType
Ethereum1ETHMainnet
Optimism10ETHL2
Arbitrum42161ETHL2
Polygon137MATICSidechain
BNB Chain56BNBL1
Avalanche43114AVAXL1
Base8453ETHL2
Zora7777777ETHL2
Blast81457ETHL2
zkSync Era324ETHL2
World Chain480ETHL2
Unichain130ETHL2
Celo42220CELOL1

Type Safety

import { ChainId, type SupportedChainsType } from '@uniswap/sdk-core-next'
 
// Type-safe chain ID
function getChainName(chainId: SupportedChainsType): string {
  switch (chainId) {
    case ChainId.MAINNET:
      return 'Ethereum'
    case ChainId.OPTIMISM:
      return 'Optimism'
    case ChainId.ARBITRUM_ONE:
      return 'Arbitrum One'
    // ... TypeScript ensures all chains are handled
    default:
      return 'Unknown'
  }
}