Configure Additional Networks using Hardhat

Guide Versions

This guide is available in multiple versions. Choose the one that matches your needs.

When working with the smart-contract-examples CCIP tutorials, you may need to add support for additional blockchain networks beyond the default testnet configurations (Avalanche Fuji, Ethereum Sepolia, Arbitrum Sepolia, and Base Sepolia, and Polygon Amoy).

This guide explains how to update the network configuration file in the Hardhat version of the repository. The configuration file stores network-specific information such as:

  • Chain ids (unique identifiers for each blockchain network)
  • Chain selectors (unique CCIP identifiers)
  • Router contract addresses
  • RMN Proxy addresses
  • Token Admin Registry addresses
  • Registry Module Owner Custom addresses
  • LINK token addresses
  • Block confirmations
  • Native currency symbols
  • Chain families (e.g., evm, svm, etc.)

These values vary by network and must be accurate for your CCIP transactions to work correctly. If you want to use additional networks (e.g., Optimism Sepolia, BNB Chain Testnet, or mainnet networks) supported by CCIP, you'll need to update the configuration file following this guide.

Find Network Configuration Values

All CCIP-supported networks and their configuration details are available in the CCIP Directory:

The CCIP Directory provides:

  • Chain selectors (unique CCIP identifiers)
  • Router contract addresses
  • RMN Proxy addresses
  • Token Admin Registry addresses
  • Registry Module Owner Custom addresses
  • LINK token addresses

Add RPC_URL Environment Variable

To add support for additional networks, you need to configure the <NEW_NETWORK_NAME>_RPC_URL environment variable in your .env.enc file. This variable should point to the RPC endpoint of the network you want to add.

npx env-enc set <NEW_NETWORK_NAME>_RPC_URL

You can obtain an RPC URL by signing up for a personal endpoint from Alchemy, Infura, or another node provider service.

Update Configuration File

File location: smart-contract-examples/ccip/cct/hardhat/config/networks.ts

Example structure:

// Rest of the code...

export const configData: Record<
  string,
  {
    chainFamily: string
    chainId: number | string
    chainSelector: string
    router?: string
    rmnProxy?: string
    tokenAdminRegistry?: string
    registryModuleOwnerCustom?: string
    link?: string
    confirmations?: number
    nativeCurrencySymbol?: string
    chainType?: string // Optional - will be auto-generated
  }
> = {
  avalancheFuji: {
    chainId: 43113,
    chainSelector: "14767482510784806043",
    router: "0xF694E193200268f9a4868e4Aa017A0118C9a8177",
    rmnProxy: "0xAc8CFc3762a979628334a0E4C1026244498E821b",
    tokenAdminRegistry: "0xA92053a4a3922084d992fD2835bdBa4caC6877e6",
    registryModuleOwnerCustom: "0x97300785aF1edE1343DB6d90706A35CF14aA3d81",
    link: "0x0b9d5D9136855f6FEc3c0993feE6E9CE8a297846",
    confirmations: 2,
    nativeCurrencySymbol: "AVAX",
    chainFamily: "evm",
  },

  // Rest of the network configurations...
}

// Rest of the code...

Steps to add a new network:

  1. Navigate to your cloned repository directory:

    cd smart-contract-examples/ccip/cct/hardhat
    
  2. Open config/networks.ts in your preferred editor

  3. Visit the CCIP Directory

  4. Locate your desired network in the directory and copy the following values:

    • Chain Selector
    • Router address
    • RMN Proxy address
    • Token Admin Registry address
    • Registry Module Owner Custom address
    • LINK token address
  5. Add a new entry to the configData object

  6. Set appropriate values for:

    • chainId: The EVM chain ID (find this on the network's official documentation or from ChainList)
    • confirmations: Number of block confirmations to wait (typically 2-3 for testnets, 5-10 for mainnet)
    • nativeCurrencySymbol: The native currency symbol (e.g., "ETH", "AVAX", "POL")
    • chainFamily: "evm" for Ethereum-compatible chains

Example: Adding Optimism Sepolia Testnet:

// Rest of the code...

export const configData = {
  // ... existing networks
  optimismSepolia: {
    chainFamily: "evm",
    chainId: 11155420,
    chainSelector: "5224473277236331295",
    router: "0x114A20A10b43D4115e5aeef7345a1A71d2a60C57",
    rmnProxy: "0xb40A3109075965cc09E93719e33E748abf680dAe",
    tokenAdminRegistry: "0x1d702b1FA12F347f0921C722f9D9166F00DEB67A",
    registryModuleOwnerCustom: "0x49c4ba01dc6F5090f9df43Ab8F79449Db91A0CBB",
    link: "0xE4aB69C077896252FAFBD49EFD26B5D171A32410",
    confirmations: 2,
    nativeCurrencySymbol: "ETH",
    chainFamily: "evm",
  },
}

// Rest of the code...

Next Steps

Once you've updated your network configuration in the smart-contract-examples repository:

  1. Fund your wallet with native tokens and LINK for the new network using the Chainlink faucets (for testnets)

  2. Test the configuration by running a simple deployment:

    npx hardhat deployToken --name "Test Token" --symbol TEST --network newNetworkName
    

    Contract Verification (Optional)

    Automatic Verification (Natively Supported): Most standard networks are natively supported by Hardhat for contract verification. Check Hardhat's chain descriptors for the complete list of supported networks.

    You just need to add the --verifycontract flag when deploying:

    npx hardhat deployToken --name "Test Token" --symbol TEST --network newNetworkName --verifycontract
    

    Or if already deployed, you can verify using the npx hardhat verify command.

    Custom Network Verification: For networks not natively supported by Hardhat, you need to add a chain descriptor to hardhat.config.ts, like:

    chainDescriptors: {
      12345: { // Your network's chainId
        name: "New Network",
        chainType: "generic",
        blockExplorers: {
          etherscan: {
            name: "NewScan",
            url: "https://newscan.io",
            apiUrl: "https://api.newscan.io/api",
          },
        },
      },
    }
    

    This is particularly useful for:

    • Newer networks not yet added to Hardhat
    • Private/enterprise chains
    • Custom testnets

    Note: With Etherscan API V2, a single ETHERSCAN_API_KEY works across all Etherscan-compatible networks.

  3. Follow the tutorials using your newly configured network

Adapt for Your Own Projects

While this guide focuses on the smart-contract-examples repository structure, you can adapt these principles for your own projects.

Get the latest Chainlink content straight to your inbox.