# CCIP Router Setup Guide ## Overview This guide explains how to set up and deploy the Chainlink CCIP Router for cross-chain oracle updates. ## Prerequisites - Chainlink CCIP Router contract deployed on source and target chains - LINK tokens for paying CCIP fees - Access to deploy contracts - Validator keys for signing transactions ## Deployment Steps ### Step 1: Get CCIP Router Addresses CCIP Router addresses vary by chain: - **Ethereum Mainnet**: `0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D` - **Polygon**: `0x3C3D92629A02a8D95D5CB9650fe49C3544f69B43` - **Avalanche**: `0xF694E193200268f9a4868e4Aa017A0118C9a8177` - **Arbitrum**: `0x1619DE6B6B20eD217a58d00f37B9d47C7663feca` - **Optimism**: `0x261c05167db67Be2E2dc4a347C4E6B000C677852` For ChainID 138, deploy a custom CCIP Router or use a compatible implementation. ### Step 2: Deploy CCIP Router (if needed) If deploying a custom CCIP Router: ```bash # Deploy CCIP Router forge script script/DeployCCIPRouter.s.sol --rpc-url $RPC_URL --broadcast ``` ### Step 3: Configure Router Address Update contract configurations: ```solidity // In CCIPSender.sol address public constant CCIP_ROUTER = 0x...; // Your router address // In CCIPReceiver.sol constructor(address _router, address _oracleAggregator) { router = IRouterClient(_router); // ... } ``` ### Step 4: Set Chain Selectors Configure chain selectors for target chains: ```solidity // Chain selectors uint64 constant ETHEREUM_MAINNET = 5009297550715157269; uint64 constant POLYGON = 4051577828743386545; uint64 constant AVALANCHE = 6433500567565415381; uint64 constant ARBITRUM = 4949039107694359620; uint64 constant OPTIMISM = 3734403246176062136; ``` ### Step 5: Fund LINK Tokens Ensure contracts have sufficient LINK tokens for fees: ```bash # Transfer LINK to sender contract cast send $SENDER_CONTRACT "transfer(address,uint256)" $LINK_TOKEN $AMOUNT --rpc-url $RPC_URL --private-key $PRIVATE_KEY ``` ### Step 6: Verify Deployment ```bash # Check router address cast call $SENDER_CONTRACT "router()" --rpc-url $RPC_URL # Check chain selector cast call $SENDER_CONTRACT "targetChainSelector()" --rpc-url $RPC_URL ``` ## Configuration Files ### Kubernetes Deployment Deploy CCIP Router service (if running as a service): ```yaml # k8s/ccip/router-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: ccip-router namespace: besu-network spec: replicas: 1 selector: matchLabels: app: ccip-router template: metadata: labels: app: ccip-router spec: containers: - name: ccip-router image: chainlink/ccip-router:v1.0.0 env: - name: RPC_URL value: "http://besu-rpc:8545" - name: PRIVATE_KEY valueFrom: secretKeyRef: name: ccip-router-secrets key: private_key ``` ### Environment Variables ```bash # .env CCIP_ROUTER_ADDRESS=0x... TARGET_CHAIN_SELECTOR=5009297550715157269 LINK_TOKEN_ADDRESS=0x... ``` ## Testing ### Test CCIP Router Connection ```bash # Test router is accessible cast call $CCIP_ROUTER "getSupportedTokens(uint64)" $CHAIN_SELECTOR --rpc-url $RPC_URL ``` ### Test Message Sending ```bash # Send test message forge script script/TestCCIPSend.s.sol --rpc-url $RPC_URL --broadcast ``` ## Monitoring Monitor CCIP Router health: - Router availability - Message processing rate - Fee consumption - Error rates See `monitoring/prometheus/alerts/ccip.yml` for alerting rules. ## Troubleshooting ### Router Not Found 1. Verify router address is correct 2. Check router is deployed on the chain 3. Verify network/chain ID matches ### Insufficient LINK 1. Check LINK balance 2. Transfer more LINK tokens 3. Monitor fee consumption ### Message Delivery Failures 1. Check target chain selector 2. Verify receiver contract address 3. Check target chain router is operational 4. Review error logs ## Security 1. **Access Control**: Restrict router configuration to authorized addresses 2. **Fee Limits**: Set maximum fee limits to prevent excessive spending 3. **Rate Limiting**: Implement rate limiting for message sending 4. **Monitoring**: Monitor for unusual activity ## References - [Chainlink CCIP Documentation](https://docs.chain.link/ccip) - [CCIP Integration Guide](docs/CCIP_INTEGRATION.md) - [CCIP Message Format](docs/CCIP_MESSAGE_FORMAT.md)