| name | description |
|---|---|
viem-chains |
Use when configuring blockchain chains with viem. Ensures correct chain imports from viem/chains before falling back to defineChain. |
When working with viem chain configurations, ALWAYS follow this order:
-
First, check the official viem chains
- Fetch: https://github.com/wevm/viem/blob/main/src/chains/index.ts
- Look for the chain export (e.g.,
monad,arbitrum,polygon)
-
If the chain exists in viem/chains:
import { monad } from 'viem/chains'
-
Only if the chain is NOT in viem/chains, use
defineChain:import { defineChain } from 'viem' export const customChain = defineChain({ id: 12345, name: 'Custom Chain', nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 }, rpcUrls: { default: { http: ['https://rpc.example.com'] }, }, })
- viem maintains up-to-date chain configurations
- Built-in chains include correct RPC URLs, block explorers, and native currency
- Avoids duplicating or misconfiguring chain data
- Ensures compatibility with future viem updates
Official viem chains source: https://github.com/wevm/viem/blob/main/src/chains/index.ts