Skip to content

Chains

The viem/chains entrypoint contains references to popular EVM-compatible chains such as: Polygon, Optimism, Avalanche, Base, Zora, and more.

Usage

Import your chain from the entrypoint and use them in the consuming viem code:

import { createPublicClient, http } from 'viem'
import { zora } from 'viem/chains'
 
const client = createPublicClient({
  chain: zora,
  transport: http()
})

See here for a list of supported chains.

Want to add a chain that's not listed in viem? Read the Contributing Guide, and then open a Pull Request with your chain.

Custom Chains

You can also extend viem to support other EVM-compatible chains by building your own chain object that inherits the Chain type.

import { defineChain } from 'viem'
 
export const zora = defineChain({
  id: 7777777,
  name: 'Zora',
  nativeCurrency: {
    decimals: 18,
    name: 'Ether',
    symbol: 'ETH',
  },
  rpcUrls: {
    default: {
      http: ['https://rpc.zora.energy'],
      webSocket: ['wss://rpc.zora.energy'],
    },
  },
  blockExplorers: {
    default: { name: 'Explorer', url: 'https://explorer.zora.energy' },
  },
  contracts: {
    multicall3: {
      address: '0xcA11bde05977b3631167028862bE2a173976CA11',
      blockCreated: 5882,
    },
  },
})