Skip to main content

1. Prerequisites

  • You have Bun installed.
  • A funded L1 wallet with ETH for both the withdrawal amount and L1 gas fees
Use a test network like Sepolia for experimentation.

2. Installation

Choose your adapter and install the SDK + adapter package:
Create a .env file in your project root:
Never commit your .env file to source control.

3. Write the withdrawal script

4. Run it

You’ll see logs for the L2 transaction, then L1 finalization readiness, L1 finalization execution, followed by updated balances.

5. Troubleshooting

  • Insufficient funds on L2: Ensure enough ETH for the withdrawal and L1 gas.
  • Invalid PRIVATE_KEY: Must be 0x + 64 hex chars.
  • Stuck at wait(…, { for: 'l1' }): Verify L2_RPC_URL and network health; check sdk.deposits.status(handle) to see the current phase.