# WETH → USDT Bridge Verification Scripts

## Overview

This directory contains verification scripts for bridging WETH from ChainID 138 to USDT on Ethereum Mainnet via thirdweb Bridge.

## Critical Finding

⚠️ **WETH is NOT at the canonical address on ChainID 138**

- **Canonical Address**: `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2` (no bytecode)
- **Actual Deployed Address**: `0x3304b747E565a97ec8AC220b0B6A1f6ffDB837e6` (has bytecode)

**Reason**: Cannot recreate CREATE-deployed contracts with CREATE2.

## Scripts

### 1. `verify-weth-usdt-bridge.sh`
Basic verification script that checks:
- Bytecode at canonical address
- ERC-20 compliance
- thirdweb Bridge route availability

**Usage**:
```bash
./scripts/verify-weth-usdt-bridge.sh
```

### 2. `verify-weth-usdt-bridge-enhanced.sh` ⭐ **Recommended**
Enhanced verification script that checks:
- Bytecode at both canonical and actual addresses
- ERC-20 compliance at actual deployed address
- thirdweb Bridge route with actual address
- Alternative routes analysis

**Usage**:
```bash
./scripts/verify-weth-usdt-bridge-enhanced.sh
```

### 3. `verify-weth-usdt-bridge.js`
Node.js verification script using:
- ethers.js for contract interaction
- thirdweb SDK for bridge verification
- Better error handling and reporting

**Usage**:
```bash
node scripts/verify-weth-usdt-bridge.js
```

**Prerequisites**:
```bash
npm install @thirdweb-dev/sdk ethers
```

## Verification Results

### Bytecode Verification
- ❌ Canonical address: No bytecode (expected)
- ⚠️ Actual address: Verification inconclusive (RPC connectivity issues)

### ERC-20 Compliance
- ⚠️ Inconclusive (depends on bytecode verification)

### thirdweb Bridge Route
- ❌ Route verification failed
- Reasons:
  1. ChainID 138 may not be supported
  2. Non-canonical address may not be recognized
  3. API requires authentication

## Recommendation

✅ **Use CCIP Bridge instead of thirdweb Bridge**

**CCIP Bridge Contract (ChainID 138)**:
- Address: `0x89dd12025bfCD38A168455A44B400e913ED33BE2`
- Already deployed and configured
- Supports actual WETH address
- Secure and audited (Chainlink CCIP)

## Documentation

- **Full Report**: `docs/WETH_USDT_BRIDGE_VERIFICATION_REPORT.md`
- **Go/No-Go Summary**: `docs/WETH_USDT_BRIDGE_GO_NOGO_SUMMARY.md`

## Quick Start

1. Run enhanced verification:
   ```bash
   ./scripts/verify-weth-usdt-bridge-enhanced.sh
   ```

2. Review results and recommendations

3. Use CCIP Bridge for actual bridging:
   ```solidity
   CCIPWETH9Bridge.bridge(amount, destinationSelector, recipient);
   ```

## Troubleshooting

### RPC Connectivity Issues
If scripts fail with RPC errors:
- Check RPC endpoint: `https://rpc-http-pub.d-bis.org`
- Verify network connectivity
- Try alternative RPC: `https://rpc-http-prv.d-bis.org`

### Missing Dependencies
For Node.js script:
```bash
npm install @thirdweb-dev/sdk ethers
```

For bash scripts:
- Requires `cast` (foundry): `curl -L https://foundry.paradigm.xyz | bash`
- Requires `jq`: `sudo apt-get install jq`

---

**Last Updated**: 2025-01-27
