Skip to content

Instantly share code, notes, and snippets.

@portdeveloper
Created January 4, 2026 08:12
Show Gist options
  • Select an option

  • Save portdeveloper/ce884b1ced46217d0b471658a904e4d1 to your computer and use it in GitHub Desktop.

Select an option

Save portdeveloper/ce884b1ced46217d0b471658a904e4d1 to your computer and use it in GitHub Desktop.
Claude Code skill for viem chain configuration - checks viem/chains before using defineChain
name description
viem-chains
Use when configuring blockchain chains with viem. Ensures correct chain imports from viem/chains before falling back to defineChain.

Viem Chain Configuration

Workflow

When working with viem chain configurations, ALWAYS follow this order:

  1. First, check the official viem chains

  2. If the chain exists in viem/chains:

    import { monad } from 'viem/chains'
  3. 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'] },
      },
    })

Why this matters

  • 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

Reference

Official viem chains source: https://github.com/wevm/viem/blob/main/src/chains/index.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment