# New Chains Added: Avalanche, Base, Arbitrum, Optimism

**Date**: 2025-12-11
**Status**: ✅ **CONFIGURED**

---

## 📋 New Chains Summary

| Chain | Chain ID | Native Token | Explorer | Status |
|-------|----------|--------------|----------|--------|
| **Avalanche** | 43114 | AVAX | Snowtrace | ✅ Added |
| **Base** | 8453 | ETH | Basescan | ✅ Added |
| **Arbitrum** | 42161 | ETH | Arbiscan | ✅ Added |
| **Optimism** | 10 | ETH | Optimistic Etherscan | ✅ Added |

---

## ✅ Configuration Updates

### 1. Foundry Configuration (`foundry.toml`)

**RPC Endpoints Added**:
- `avalanche = "${AVALANCHE_RPC_URL}"`
- `base = "${BASE_RPC_URL}"`
- `arbitrum = "${ARBITRUM_RPC_URL}"`
- `optimism = "${OPTIMISM_RPC_URL}"`

**Explorer Configuration Added**:
- `avalanche = { key = "${SNOWTRACE_API_KEY}", chain = "avalanche" }`
- `base = { key = "${BASESCAN_API_KEY}", chain = "base" }`
- `arbitrum = { key = "${ARBISCAN_API_KEY}", chain = "arbitrum" }`
- `optimism = { key = "${OPTIMISTIC_ETHERSCAN_API_KEY}", chain = "optimism" }`

**Profiles Added**:
- `[profile.avalanche]` - Chain ID 43114
- `[profile.base]` - Chain ID 8453
- `[profile.arbitrum]` - Chain ID 42161
- `[profile.optimism]` - Chain ID 10

### 2. Deployment Script (`script/DeployAll.s.sol`)

**Chain Constants Added**:
```solidity
uint256 constant AVALANCHE = 43114;
uint256 constant BASE = 8453;
uint256 constant ARBITRUM = 42161;
uint256 constant OPTIMISM = 10;
```

**CCIP Configuration Added**:
- `CCIP_AVALANCHE_ROUTER`
- `CCIP_AVALANCHE_LINK_TOKEN`
- `AVALANCHE_SELECTOR`
- Similar for Base, Arbitrum, Optimism

**WETH Configuration Added**:
- `WETH9_AVALANCHE` / `WETH10_AVALANCHE` (optional)
- Similar for Base, Arbitrum, Optimism

### 3. Gas Price Script (`scripts/deployment/get-multichain-gas-prices.sh`)

**Gas Price Functions Added**:
- `get_avalanche_gas_price()`
- `get_base_gas_price()`
- `get_arbitrum_gas_price()`
- `get_optimism_gas_price()`

**Cost Calculations Added**:
- All 4 new chains included in cost calculations
- USD rates configured (AVAX: $35, others use ETH rate: $2500)

---

## 🔧 Environment Variables Required

Add to `.env`:

```bash
# RPC URLs
AVALANCHE_RPC_URL=https://avalanche-mainnet.infura.io/v3/YOUR_KEY
BASE_RPC_URL=https://mainnet.base.org
ARBITRUM_RPC_URL=https://arb1.arbitrum.io/rpc
OPTIMISM_RPC_URL=https://mainnet.optimism.io

# Explorer API Keys
SNOWTRACE_API_KEY=your_snowtrace_api_key
BASESCAN_API_KEY=your_basescan_api_key
ARBISCAN_API_KEY=your_arbiscan_api_key
OPTIMISTIC_ETHERSCAN_API_KEY=your_optimistic_etherscan_api_key

# CCIP Configuration - Avalanche
CCIP_AVALANCHE_ROUTER=0xF694E193200268f9a4868e4Aa017A0118C9a8177
CCIP_AVALANCHE_LINK_TOKEN=0x5947BB275c521040051E823961ee81e07Ca0C08A
AVALANCHE_SELECTOR=6433500567565415381

# CCIP Configuration - Base
CCIP_BASE_ROUTER=0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D
CCIP_BASE_LINK_TOKEN=0x88Fb150BDc53A65fe94Dea0c9BA0a6dAf8C6e396
BASE_SELECTOR=15971525489660198786

# CCIP Configuration - Arbitrum
CCIP_ARBITRUM_ROUTER=0x1619DE6B6B20eD217a58d00f37B9d47C7663feca
CCIP_ARBITRUM_LINK_TOKEN=0xf97f4df75117a78c1A5a0DBb814Af92458539FB4
ARBITRUM_SELECTOR=4949039107694359620

# CCIP Configuration - Optimism
CCIP_OPTIMISM_ROUTER=0x261c05167db67Be2E2dc4a347C4E6B000C677852
CCIP_OPTIMISM_LINK_TOKEN=0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6
OPTIMISM_SELECTOR=3734403246176062136

# Optional: WETH addresses (if using existing)
WETH9_AVALANCHE=0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB
WETH10_AVALANCHE=0x0
WETH9_BASE=0x4200000000000000000000000000000000000006
WETH10_BASE=0x0
WETH9_ARBITRUM=0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
WETH10_ARBITRUM=0x0
WETH9_OPTIMISM=0x4200000000000000000000000000000000000006
WETH10_OPTIMISM=0x0
```

---

## 📊 Contracts to Deploy

Each new chain requires **5 contracts**:
1. WETH9
2. WETH10
3. CCIPWETH9Bridge
4. CCIPWETH10Bridge
5. CCIPLogger

**Total**: 20 additional contracts (5 per chain × 4 chains)

---

## 🚀 Deployment Commands

### Avalanche
```bash
forge script script/DeployAll.s.sol:DeployAll \
  --rpc-url avalanche --chain-id 43114 \
  --private-key $PRIVATE_KEY --broadcast --verify -vvvv
```

### Base
```bash
forge script script/DeployAll.s.sol:DeployAll \
  --rpc-url base --chain-id 8453 \
  --private-key $PRIVATE_KEY --broadcast --verify -vvvv
```

### Arbitrum
```bash
forge script script/DeployAll.s.sol:DeployAll \
  --rpc-url arbitrum --chain-id 42161 \
  --private-key $PRIVATE_KEY --broadcast --verify -vvvv
```

### Optimism
```bash
forge script script/DeployAll.s.sol:DeployAll \
  --rpc-url optimism --chain-id 10 \
  --private-key $PRIVATE_KEY --broadcast --verify -vvvv
```

---

## 💰 Gas Cost Estimates

**Per Chain** (all 5 contracts):
- **Avalanche**: ~8,760,000 gas units
- **Base**: ~8,760,000 gas units
- **Arbitrum**: ~8,760,000 gas units
- **Optimism**: ~8,760,000 gas units

**Note**: Run `./scripts/deployment/get-multichain-gas-prices.sh` for real-time estimates.

---

## ✅ Next Steps

1. **Configure `.env`** with all required variables
2. **Fund wallets** on each chain with native tokens
3. **Test gas price fetching**: `./scripts/deployment/get-multichain-gas-prices.sh`
4. **Deploy contracts** to each chain

---

**Total Chains Now Supported**: 9 (Ethereum Mainnet, Cronos, BSC, Polygon, Gnosis, Avalanche, Base, Arbitrum, Optimism)

