3.2 KiB
3.2 KiB
WETH Unwrap Script Instructions
Quick Start
This script will help you get your WETH back if the wrapping transaction failed.
Step 1: Check Prerequisites
# Install required packages if not already installed
pip install web3 eth-account python-dotenv
Step 2: Verify Environment Setup
Ensure your .env file contains:
MAINNET_RPC_URL=https://arb1.arbitrum.io/rpc
MAIN_WALLET_PRIVATE_KEY=0x_your_private_key_here
Step 3: Run the Script
python unwrap_weth.py
What the Script Does
- Checks your balances - Shows current WETH and ETH balance
- Checks failed transaction - Verifies status of your previous wrap attempt
- Offers unwrap options:
- Unwrap all WETH
- Unwrap specific amount
- Executes with high gas - Uses 3x gas price to ensure success
- Monitors transaction - Waits up to 10 minutes for confirmation
Important Features
✅ Safe Transaction Management
- Uses higher gas limits (150k gas)
- 3x gas price multiplier for faster processing
- 10-minute timeout for network congestion
- Confirmation before executing
✅ Error Handling
- Checks if previous transaction actually succeeded
- Handles network errors gracefully
- Detailed logging to
unwrap_weth.log
✅ Transaction Monitoring
- Provides Arbiscan links for tracking
- Shows before/after balances
- Clear success/failure reporting
Expected Output
=== WETH Unwrap Script ===
✅ Connected to Chain ID: 42161
Wallet: 0xYourAddress...
Current WETH Balance: 0.016483 WETH
Current ETH Balance: 1.234567 ETH
Checking your failed transaction: 0x12c38f989...
You have 0.016483 WETH available
Options:
1. Unwrap all WETH
2. Unwrap specific amount
3. Exit
Enter your choice (1, 2, or 3): 1
Confirm unwrap 0.016483 WETH? (y/N): y
Sending WETH unwrap transaction...
Transaction sent: 0xabcdef123...
Arbiscan: https://arbiscan.io/tx/0xabcdef123...
✅ WETH unwrap successful!
Troubleshooting
If script fails with connection error:
- Check your RPC URL in .env file
- Try a different RPC endpoint:
MAINNET_RPC_URL=https://arbitrum-one.public.blastapi.io
If transaction still fails:
- Network may be congested, try again later
- Check your ETH balance for gas fees
- The script automatically uses high gas prices
If you see "No WETH balance":
- Your previous transaction may have succeeded
- Check Arbiscan for the transaction hash
- Your ETH should already be back
Safety Notes
⚠️ Always verify:
- Transaction details before confirming
- Final balances after operation
- Transaction on Arbiscan
✅ Script protections:
- Will never exceed your WETH balance
- Asks for confirmation before any transaction
- Uses reasonable gas limits
- Logs all operations
After Success
Once the unwrap completes:
- Your WETH will be converted back to native ETH
- You can check the transaction on Arbiscan
- Your ETH balance will increase by the unwrapped amount
- Your WETH balance will decrease to 0 (if unwrapping all)
Support
If you encounter issues:
- Check the
unwrap_weth.logfile for detailed error messages - Verify your .env file configuration
- Ensure you have sufficient ETH for gas fees
- Try running the script again (it will re-check transaction status)