Files
smom-dbis-138/docs/operations/WRAP_AND_BRIDGE_WETH9_TO_MAINNET.md

5.5 KiB

Wrap ETH to WETH9 and Bridge to Ethereum Mainnet

Purpose: Guide for wrapping ETH to WETH9 on Chain 138 and bridging to Ethereum Mainnet


Quick Start

# Wrap and bridge 20,000 ETH to Ethereum Mainnet
cd /home/intlc/projects/proxmox/smom-dbis-138
./scripts/wrap-and-bridge-weth9-to-mainnet.sh 20000 <recipient_address> <private_key>

# Or use environment variable for private key
export PRIVATE_KEY=0x...
./scripts/wrap-and-bridge-weth9-to-mainnet.sh 20000 <recipient_address>

Prerequisites

  1. ETH Balance: Sufficient ETH on Chain 138 for wrapping
  2. LINK Tokens: LINK tokens for paying CCIP fees (typically 0.1-2 LINK)
  3. Private Key: Wallet with ETH and LINK tokens
  4. Recipient Address: Ethereum Mainnet address to receive WETH9 (can be same as sender)

Contract Addresses

Chain 138

  • WETH9: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
  • CCIPWETH9Bridge: 0x89dd12025bfCD38A168455A44B400e913ED33BE2
  • LINK Token: 0x514910771AF9Ca656af840dff83E8264EcF986CA

Ethereum Mainnet

  • WETH9: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 (same address)
  • CCIPWETH9Bridge: 0x2A0840e5117683b11682ac46f5CF5621E67269E3
  • Chain Selector: 5009297550715157269

Process Flow

1. Check ETH Balance
   ↓
2. Wrap ETH → WETH9 (deposit())
   ↓
3. Approve Bridge (approve())
   ↓
4. Check LINK Balance
   ↓
5. Bridge to Mainnet (sendCrossChain())
   ↓
6. Wait for CCIP Confirmation (1-5 minutes)
   ↓
7. WETH9 appears on Ethereum Mainnet

Step-by-Step Manual Process

Step 1: Wrap ETH to WETH9

AMOUNT_WEI=$(cast --to-wei 20000 ether)

cast send "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
  "deposit()" \
  --value "$AMOUNT_WEI" \
  --rpc-url http://192.168.11.250:8545 \
  --private-key 0x... \
  --gas-price 20000000000 \
  --legacy

Step 2: Approve Bridge

MAX_UINT256="115792089237316195423570985008687907853269984665640564039457584007913129639935"

cast send "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
  "approve(address,uint256)" \
  "0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
  "$MAX_UINT256" \
  --rpc-url http://192.168.11.250:8545 \
  --private-key 0x... \
  --gas-price 20000000000 \
  --legacy

Step 3: Bridge to Ethereum Mainnet

RECIPIENT="0xYourMainnetAddress"
ETHEREUM_SELECTOR="5009297550715157269"
AMOUNT_WEI=$(cast --to-wei 20000 ether)

cast send "0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
  "sendCrossChain(uint64,address,uint256)" \
  "$ETHEREUM_SELECTOR" \
  "$RECIPIENT" \
  "$AMOUNT_WEI" \
  --rpc-url http://192.168.11.250:8545 \
  --private-key 0x... \
  --gas-price 20000000000 \
  --legacy

Verification

Check WETH9 Balance (Chain 138)

cast call "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
  "balanceOf(address)" \
  "0xYourAddress" \
  --rpc-url http://192.168.11.250:8545

Check Bridge Allowance

cast call "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
  "allowance(address,address)" \
  "0xYourAddress" \
  "0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
  --rpc-url http://192.168.11.250:8545

Check WETH9 Balance (Ethereum Mainnet)

After bridge completes (wait 1-5 minutes):

cast call "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
  "balanceOf(address)" \
  "0xYourMainnetAddress" \
  --rpc-url https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY

Safety Considerations

Large Amount Warnings

For amounts > 1,000 ETH, the script will:

  • Display warning messages
  • Request confirmation before wrapping
  • Request final confirmation before bridging

Gas Fees

  • Wrap Transaction: ~50,000 gas
  • Approve Transaction: ~50,000 gas
  • Bridge Transaction: ~200,000-500,000 gas
  • CCIP Fees: Paid in LINK tokens (0.1-2 LINK typically)

Timing

  • Wrap: ~15 seconds (block confirmation)
  • Approve: ~10 seconds (block confirmation)
  • Bridge: ~1-5 minutes (CCIP confirmation)

Troubleshooting

Insufficient ETH Balance

Error: Insufficient ETH balance

Solution: Ensure you have enough ETH to cover:

  • Amount to wrap
  • Gas fees for all transactions
Warning: Low LINK balance

Solution: Acquire LINK tokens on Chain 138 for CCIP fees

Bridge Transaction Fails

Possible Causes:

  1. Destination not configured on bridge
  2. Insufficient LINK for fees
  3. Insufficient gas

Solution: Check bridge destination configuration:

cast call "0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
  "destinations(uint64)" \
  "5009297550715157269" \
  --rpc-url http://192.168.11.250:8545

Example: Bridge 20,000 ETH

# Set environment
export PRIVATE_KEY=0xYourPrivateKey
export RPC_URL_138=http://192.168.11.250:8545

# Execute bridge
./scripts/wrap-and-bridge-weth9-to-mainnet.sh 20000 0xYourMainnetAddress

# The script will:
# 1. Check ETH balance
# 2. Wrap 20,000 ETH to WETH9
# 3. Approve bridge
# 4. Bridge to Ethereum Mainnet
# 5. Display transaction hash and next steps

Cost Estimate (20,000 ETH)

Item Cost
Wrap Gas ~0.001 ETH
Approve Gas ~0.001 ETH
Bridge Gas ~0.005 ETH
CCIP Fee (LINK) ~0.5-2 LINK
Total ETH Cost ~0.007 ETH
Total LINK Cost ~0.5-2 LINK


Last Updated: 2025-01-12