127 lines
3.1 KiB
Markdown
127 lines
3.1 KiB
Markdown
# Quick Reference: Wrap ETH to WETH9 and Bridge to Ethereum Mainnet
|
|
|
|
## One-Line Command
|
|
|
|
```bash
|
|
./scripts/wrap-and-bridge-to-ethereum.sh <amount_in_eth> [private_key]
|
|
```
|
|
|
|
## Example
|
|
|
|
```bash
|
|
# With PRIVATE_KEY in .env file
|
|
./scripts/wrap-and-bridge-to-ethereum.sh 1.0
|
|
|
|
# With private key as argument
|
|
./scripts/wrap-and-bridge-to-ethereum.sh 1.0 0xYourPrivateKeyHere
|
|
```
|
|
|
|
## Manual Commands
|
|
|
|
### 1. Wrap ETH to WETH9
|
|
```bash
|
|
cast send "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" "deposit()" \
|
|
--value $(cast --to-wei 1.0 ether) \
|
|
--rpc-url "http://192.168.11.250:8545" \
|
|
--private-key "0xYourPrivateKey" \
|
|
--gas-price 5000000000
|
|
```
|
|
|
|
### 2. Approve Bridge
|
|
```bash
|
|
cast send "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
|
|
"approve(address,uint256)" \
|
|
"0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
|
|
"115792089237316195423570985008687907853269984665640564039457584007913129639935" \
|
|
--rpc-url "http://192.168.11.250:8545" \
|
|
--private-key "0xYourPrivateKey" \
|
|
--gas-price 5000000000
|
|
```
|
|
|
|
### 3. Bridge to Ethereum Mainnet
|
|
```bash
|
|
cast send "0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
|
|
"sendCrossChain(uint64,address,uint256)" \
|
|
"5009297550715157269" \
|
|
"$(cast wallet address --private-key 0xYourPrivateKey)" \
|
|
$(cast --to-wei 1.0 ether) \
|
|
--rpc-url "http://192.168.11.250:8545" \
|
|
--private-key "0xYourPrivateKey" \
|
|
--gas-price 5000000000
|
|
```
|
|
|
|
## Contract Addresses
|
|
|
|
| Contract | Address |
|
|
|----------|---------|
|
|
| WETH9 | `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2` |
|
|
| WETH9 Bridge | `0x89dd12025bfCD38A168455A44B400e913ED33BE2` |
|
|
| Ethereum Mainnet Selector | `5009297550715157269` |
|
|
| RPC URL | `http://192.168.11.250:8545` |
|
|
|
|
## Process Flow
|
|
|
|
```
|
|
ETH Balance
|
|
↓
|
|
[Wrap ETH] → deposit() with value
|
|
↓
|
|
WETH9 Balance
|
|
↓
|
|
[Approve Bridge] → approve(bridge, max)
|
|
↓
|
|
Bridge Allowance
|
|
↓
|
|
[Bridge] → sendCrossChain(selector, recipient, amount)
|
|
↓
|
|
Ethereum Mainnet
|
|
```
|
|
|
|
## Check Status
|
|
|
|
```bash
|
|
# Get address from private key
|
|
DEPLOYER=$(cast wallet address --private-key "0xYourPrivateKey")
|
|
|
|
# Check ETH balance
|
|
cast balance "$DEPLOYER" --rpc-url "http://192.168.11.250:8545"
|
|
|
|
# Check WETH9 balance
|
|
cast call "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
|
|
"balanceOf(address)" "$DEPLOYER" \
|
|
--rpc-url "http://192.168.11.250:8545"
|
|
|
|
# Check bridge allowance
|
|
cast call "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" \
|
|
"allowance(address,address)" \
|
|
"$DEPLOYER" \
|
|
"0x89dd12025bfCD38A168455A44B400e913ED33BE2" \
|
|
--rpc-url "http://192.168.11.250:8545"
|
|
```
|
|
|
|
## Requirements
|
|
|
|
- **Foundry** (`cast` command)
|
|
- **Private key** with sufficient ETH
|
|
- **Amount + 0.01 ETH** for gas fees
|
|
|
|
## Time Estimates
|
|
|
|
- Wrap ETH: ~15 seconds
|
|
- Approve Bridge: ~15 seconds
|
|
- Bridge Transfer: 5-15 minutes (CCIP processing)
|
|
|
|
## Troubleshooting
|
|
|
|
| Issue | Solution |
|
|
|-------|----------|
|
|
| Insufficient balance | Check ETH balance, need amount + gas |
|
|
| Transaction failed | Check gas price, nonce, or network |
|
|
| Bridge not approved | Run approve step first |
|
|
| Bridge failed | Check CCIP fee, ensure sufficient LINK if required |
|
|
|
|
## Full Documentation
|
|
|
|
See [WRAP_AND_BRIDGE_TO_ETHEREUM.md](./WRAP_AND_BRIDGE_TO_ETHEREUM.md) for detailed instructions and code examples.
|
|
|