|
| 1 | +--- |
| 2 | +section: ccip |
| 3 | +date: Last Modified |
| 4 | +title: "Add CCIP Networks for Cross-Chain Token Tutorials (Foundry)" |
| 5 | +metadata: |
| 6 | + description: "Add CCIP network support to test burn-mint and lock-mint token tutorials on additional blockchains. Configure network settings, RPC endpoints, and CCIP contract addresses in Foundry." |
| 7 | + excerpt: "burn-mint, lock-mint, token pools, CCIP networks, add network, Foundry configuration, cross-chain tokens, testnet, mainnet, RPC endpoints, CCIP Directory, EVM chains, network setup" |
| 8 | + image: "/images/ccip/CCIP_enabled_tokens_flowchart.jpg" |
| 9 | + datePublished: "2025-10-30" |
| 10 | + lastModified: "2025-10-30" |
| 11 | + estimatedTime: "5 minutes" |
| 12 | + difficulty: "beginner" |
| 13 | +--- |
| 14 | + |
| 15 | +import { Aside, PageTabs } from "@components" |
| 16 | + |
| 17 | +<PageTabs |
| 18 | + pages={[ |
| 19 | + { |
| 20 | + name: "Hardhat", |
| 21 | + url: "/ccip/tutorials/evm/cross-chain-tokens/configure-additional-networks-hardhat", |
| 22 | + icon: "/images/tutorial-icons/hardhat-icn.png", |
| 23 | + }, |
| 24 | + { |
| 25 | + name: "Foundry", |
| 26 | + url: "/ccip/tutorials/evm/cross-chain-tokens/configure-additional-networks-foundry", |
| 27 | + icon: "/images/tutorial-icons/foundry-icn.png", |
| 28 | + }, |
| 29 | + ]} |
| 30 | +/> |
| 31 | + |
| 32 | +The [smart-contract-examples](https://github.com/smartcontractkit/smart-contract-examples/tree/main/ccip/cct/foundry) repository includes default configurations for common CCIP testnet networks. This guide shows how to add support for additional networks. |
| 33 | + |
| 34 | +## Add a Network |
| 35 | + |
| 36 | +Add the network configuration to [`script/HelperConfig.s.sol`](https://github.com/smartcontractkit/smart-contract-examples/blob/main/ccip/cct/foundry/script/HelperConfig.s.sol) |
| 37 | + |
| 38 | +```solidity |
| 39 | +// Rest of the code... |
| 40 | +
|
| 41 | +constructor() { |
| 42 | + // Rest of the existing networks... |
| 43 | +
|
| 44 | + else if (block.chainid == 11155420) { |
| 45 | + activeNetworkConfig = getOptimismSepoliaConfig(); |
| 46 | + } else { |
| 47 | + revert("Unsupported network"); |
| 48 | + } |
| 49 | +} |
| 50 | +
|
| 51 | +// Rest of the existing network configurations... |
| 52 | +
|
| 53 | +function getOptimismSepoliaConfig() public pure returns (NetworkConfig memory) { |
| 54 | + NetworkConfig memory optimismSepoliaConfig = NetworkConfig({ |
| 55 | + chainSelector: 5224473277236331295, |
| 56 | + router: 0x114A20A10b43D4115e5aeef7345a1A71d2a60C57, |
| 57 | + rmnProxy: 0xb40A3109075965cc09E93719e33E748abf680dAe, |
| 58 | + tokenAdminRegistry: 0x1d702b1FA12F347f0921C722f9D9166F00DEB67A, |
| 59 | + registryModuleOwnerCustom: 0x49c4ba01dc6F5090f9df43Ab8F79449Db91A0CBB, |
| 60 | + link: 0xE4aB69C077896252FAFBD49EFD26B5D171A32410, |
| 61 | + confirmations: 2, |
| 62 | + nativeCurrencySymbol: "ETH" |
| 63 | + }); |
| 64 | + return optimismSepoliaConfig; |
| 65 | +} |
| 66 | +
|
| 67 | +function getNetworkConfig(uint256 chainId) public pure returns (NetworkConfig memory) { |
| 68 | + // Rest of the existing networks... |
| 69 | +
|
| 70 | + else if (chainId == 11155420) { |
| 71 | + return getOptimismSepoliaConfig(); |
| 72 | + } else { |
| 73 | + revert("Unsupported chain ID"); |
| 74 | + } |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +Set the RPC URL: |
| 79 | + |
| 80 | +```env |
| 81 | +RPC_URL_OPTIMISM_SEPOLIA="INSERT_YOUR_RPC_URL_HERE" |
| 82 | +``` |
| 83 | + |
| 84 | +<Aside type="note" title="Note"> |
| 85 | + You can obtain RPC URLs from [Alchemy](https://www.alchemy.com/), [Infura](https://www.infura.io/), or another node |
| 86 | + provider. |
| 87 | +</Aside> |
| 88 | + |
| 89 | +Save the `.env` file, then load the environment variable into the terminal session: |
| 90 | + |
| 91 | +```bash |
| 92 | +source .env |
| 93 | +``` |
| 94 | + |
| 95 | +The network is now available in all Foundry commands using `--rpc-url $RPC_URL_OPTIMISM_SEPOLIA`. |
| 96 | + |
| 97 | +## Configuration Fields |
| 98 | + |
| 99 | +| Field | Required | Description | Source | |
| 100 | +| --------------------------- | -------- | ------------------------------------------------------------------ | ------------------------------------------------------------- | |
| 101 | +| `chainSelector` | Yes | CCIP identifier for the network | [CCIP Directory](/ccip/directory) | |
| 102 | +| `router` | Yes | CCIP Router contract address | [CCIP Directory](/ccip/directory) | |
| 103 | +| `rmnProxy` | Yes | RMN Proxy contract address | [CCIP Directory](/ccip/directory) | |
| 104 | +| `tokenAdminRegistry` | Yes | Token Admin Registry address | [CCIP Directory](/ccip/directory) | |
| 105 | +| `registryModuleOwnerCustom` | Yes | Registry Module Owner address | [CCIP Directory](/ccip/directory) | |
| 106 | +| `link` | Yes | LINK token contract address | [CCIP Directory](/ccip/directory) | |
| 107 | +| `confirmations` | No | Number of block confirmations before considering transaction final | Blockchain's finality characteristics and your risk tolerance | |
| 108 | +| `nativeCurrencySymbol` | No | Native gas token symbol (e.g., `"ETH"`, `"AVAX"`, `"POL"`) | Blockchain's official documentation | |
| 109 | + |
| 110 | +Find all CCIP addresses in the [CCIP Directory - Testnet](/ccip/directory/testnet) or [CCIP Directory - Mainnet](/ccip/directory/mainnet). |
| 111 | + |
| 112 | +## Test |
| 113 | + |
| 114 | +Deploy a token to verify the configuration: |
| 115 | + |
| 116 | +```bash |
| 117 | +forge script script/DeployToken.s.sol --rpc-url $RPC_URL_OPTIMISM_SEPOLIA --private-key $PRIVATE_KEY --broadcast |
| 118 | +``` |
| 119 | + |
| 120 | +## Contract Verification (Optional) |
| 121 | + |
| 122 | +Most networks are natively supported. Add `--verify` when deploying: |
| 123 | + |
| 124 | +```bash |
| 125 | +forge script script/DeployToken.s.sol --rpc-url $RPC_URL_OPTIMISM_SEPOLIA --private-key $PRIVATE_KEY --broadcast --verify |
| 126 | +``` |
| 127 | + |
| 128 | +For networks not in [Foundry's `StdChains.sol::StdChains::initializeStdChains()`](https://github.com/foundry-rs/forge-std/blob/master/src/StdChains.sol#L193) function, include the `--verifier`, `--verifier-url`, and `--verifier-api-key` flags together with `--verify` when deploying: |
| 129 | + |
| 130 | +```bash |
| 131 | +forge script script/DeployToken.s.sol --rpc-url $RPC_URL_CUSTOM_NETWORK --private-key $PRIVATE_KEY --broadcast --verify --verifier custom --verifier-url $CUSTOM_EXPLORER_API_URL --verifier-api-key $CUSTOM_EXPLORER_API_KEY |
| 132 | +``` |
| 133 | + |
| 134 | +With [Etherscan API V2](https://docs.etherscan.io/introduction), a single `ETHERSCAN_API_KEY` works across all Etherscan-compatible networks. |
0 commit comments