# Wallet Requirements for Deployment

## Overview

Before deploying bridge contracts, ensure your wallet has sufficient balances for gas fees and operations.

## Required Balances

### Ethereum Mainnet

| Token | Purpose | Minimum Required | Recommended |
|-------|---------|------------------|-------------|
| **ETH** | Gas fees for deployment | 0.025 ETH | 0.05 ETH (buffer) |
| **LINK** | CCIP fees (not for deployment) | 0 | 10 LINK (for testing) |

**Breakdown**:
- Deploy CCIPWETH9Bridge: ~0.00789 ETH
- Deploy CCIPWETH10Bridge: ~0.00789 ETH
- Configure destinations (4 calls): ~0.006 ETH
- **Total: ~0.02178 ETH**
- **Recommended buffer: 0.05 ETH** (for unexpected gas spikes)

### ChainID 138

| Token | Purpose | Minimum Required | Recommended |
|-------|---------|------------------|-------------|
| **ETH** | Gas fees for deployment | 1 ETH | 2 ETH (buffer) |
| **LINK** | CCIP fees (not for deployment) | 0 | 10 LINK (for testing) |

**Breakdown**:
- Deploy CCIPWETH9Bridge: ~0.001 ETH (estimate)
- Deploy CCIPWETH10Bridge: ~0.001 ETH (estimate)
- Configure destinations (4 calls): ~0.001 ETH
- **Total: ~0.003 ETH**
- **Recommended buffer: 2 ETH** (for future operations)

## Pre-Deployment Check

Run the balance checker before deployment:

```bash
./scripts/deployment/check-wallet-balances.sh
```

This script will:
- ✅ Check ETH balance on Mainnet
- ✅ Check ETH balance on ChainID 138
- ✅ Check LINK balance (if configured)
- ✅ Verify sufficient funds for deployment
- ✅ Provide deficit amounts if insufficient

## Funding Your Wallet

### Mainnet ETH

**Option 1: Exchange Transfer**
1. Buy ETH on an exchange (Coinbase, Binance, etc.)
2. Withdraw to your wallet address
3. Wait for confirmation (usually 1-2 hours)

**Option 2: Bridge from Layer 2**
1. Use a bridge (Arbitrum, Optimism, etc.)
2. Bridge ETH to Mainnet
3. Wait for confirmation

**Option 3: Receive from Another Wallet**
1. Send ETH from another wallet
2. Wait for confirmation

### ChainID 138 ETH

**Option 1: Faucet (if available)**
```bash
# Check if faucet exists
curl -X POST $RPC_URL \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["'$WALLET_ADDRESS'","latest"],"id":1}'
```

**Option 2: Transfer from Validator**
- If you control a validator, you can transfer ETH

**Option 3: Pre-fund in Genesis**
- Add your wallet address to genesis.json `alloc` section

### LINK Token

LINK is **not required for deployment**, only for:
- Paying CCIP fees when users bridge tokens
- Testing cross-chain transfers

**To get LINK on Mainnet**:
- Buy on an exchange
- Use Uniswap or other DEX
- Mainnet LINK address: `0x514910771AF9Ca656af840dff83E8264EcF986CA`

**To get LINK on ChainID 138**:
- Deploy MockLinkToken (for testing)
- Or deploy real LINK token if available

## Environment Variables

Ensure these are set in `.env`:

```bash
# Wallet
PRIVATE_KEY=your-private-key

# Mainnet
MAINNET_RPC_URL=https://eth.llamarpc.com
MAINNET_LINK_TOKEN=0x514910771AF9Ca656af840dff83E8264EcF986CA

# ChainID 138
RPC_URL=https://rpc.d-bis.org
LINK_TOKEN=<link-token-address>
```

## Verification Steps

1. **Check balances**:
   ```bash
   ./scripts/deployment/check-wallet-balances.sh
   ```

2. **Verify wallet address**:
   ```bash
   cast wallet address --private-key $PRIVATE_KEY
   ```

3. **Check Mainnet ETH**:
   ```bash
   cast balance $WALLET_ADDRESS --rpc-url $MAINNET_RPC_URL
   ```

4. **Check ChainID 138 ETH**:
   ```bash
   cast balance $WALLET_ADDRESS --rpc-url $RPC_URL
   ```

## Troubleshooting

### Error: "Insufficient balance"

**Solution**: Fund your wallet with the required amount:
- Mainnet: Send ETH to your wallet address
- ChainID 138: Use faucet or transfer from validator

### Error: "Could not derive address"

**Solution**: Check that `PRIVATE_KEY` is correctly set in `.env`:
```bash
echo $PRIVATE_KEY | wc -c  # Should be 66 (0x + 64 hex chars)
```

### Error: "RPC URL not accessible"

**Solution**: 
- Check RPC URL is correct
- Try alternative RPC endpoints
- Check network connectivity

## Cost Summary

### Mainnet Deployment

| Item | Cost |
|------|------|
| Deploy CCIPWETH9Bridge | ~0.00789 ETH |
| Deploy CCIPWETH10Bridge | ~0.00789 ETH |
| Configure destinations | ~0.006 ETH |
| **Total** | **~0.02178 ETH** |
| **Recommended Buffer** | **0.05 ETH** |

### ChainID 138 Deployment

| Item | Cost |
|------|------|
| Deploy CCIPWETH9Bridge | ~0.001 ETH (estimate) |
| Deploy CCIPWETH10Bridge | ~0.001 ETH (estimate) |
| Configure destinations | ~0.001 ETH (estimate) |
| **Total** | **~0.003 ETH** |
| **Recommended Buffer** | **2 ETH** |

## Next Steps

After verifying balances:

1. ✅ Run pre-deployment check: `./scripts/deployment/check-wallet-balances.sh`
2. ✅ Deploy on ChainID 138: `./scripts/deployment/deploy-bridges-chain138.sh`
3. ✅ Deploy on Mainnet: `./scripts/deployment/deploy-bridges-mainnet.sh`
4. ✅ Configure bridges: See `docs/BRIDGE_CONFIGURATION.md`
