> ## Documentation Index
> Fetch the complete documentation index at: https://metalayerlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ETH Withdrawal Guide

This guide covers the steps necessary to bridge ETH from Blast (L2) to Ethereum (L1). The guide is geared towards exchanges and other custodians that need to bridge ETH from contracts on L2, such as multisigs or custody contracts.

The steps on Blast are calls made by the contract that holds your ETH; each lists the contract, function, arguments, and ETH value, so you can execute them with whatever your contract or custody platform supports. The steps on Ethereum can be sent from any account; see [Building the Prove and Finalize Transactions](#building-the-prove-and-finalize-transactions) for TypeScript code examples.

## How It Works

ETH bridged to Blast is held on Ethereum by Blast's **ETHYieldManager**, which earns Blast's native yield on it. Withdrawals use the standard OP Stack bridge together with Blast's **ETH withdrawal queue**:

* **On Blast**, your ETH is sent to the **L2BlastBridge**, which starts the withdrawal.
* **When you prove** on Ethereum, the withdrawal is added to the ETH withdrawal queue.
* **When you finalize**, the ETH is claimed from the queue and sent to your recipient.

| Stage | Network | Function called |
| - | - | - |
| Unwrap WETH (if needed) | Blast (L2) | `withdraw` on WETH |
| Initiate | Blast (L2) | `bridgeETHTo` on the L2BlastBridge |
| *Wait up to \~1 hour until ready to prove* | | |
| Prove | Ethereum (L1) | `proveWithdrawalTransaction` on the OptimismPortal |
| *Wait **1 day** for the challenge period* | | |
| Finalize | Ethereum (L1) | `finalizeWithdrawalTransaction` on the OptimismPortal |

## Before You Start

### Your L2 Contract Must Be Able to Call the Bridge

The withdrawal is initiated by **the contract that holds the ETH** on the L2. It must be able to make the following contract calls: `bridgeETHTo` on the L2BlastBridge with ETH attached, and `withdraw` on WETH if it holds WETH. A contract that can only transfer tokens to an address can't start a withdrawal itself; move the ETH to a contract or account that can.

### Verify Your L1 Recipient

Before you start, verify that the intended recipient address meets the following conditions:

* **It exists on Ethereum.** There is contract code at the address, or it's an EOA you control. If nothing is deployed there yet, the ETH still arrives, but whoever later deploys a contract at that address controls it. A not-yet-deployed multisig must later be deployed with exactly the same configuration to reach the same address.
* **It's the contract you expect.** Its source is verified and it's the contract type you intended. For a multisig, it has the owners and threshold you expect.
* **It can receive ETH.** It must accept plain ETH transfers with empty calldata (a `receive()` or payable `fallback()` function). If it rejects the ETH, the delivery fails (see [Delivered?](#delivered)).
* **It can transfer the ETH out.** It must be able to send ETH it holds to another address. A contract that can receive ETH but not send it leaves the ETH stuck permanently.

### Anyone Can Prove and Finalize

`proveWithdrawalTransaction` and `finalizeWithdrawalTransaction` on Ethereum don't check who sends them. Any EOA with ETH for gas can submit them; your L2 contract and its signers don't need to do anything on Ethereum.

### Test With a Small Amount First

Be sure to run the whole flow end-to-end with a small amount before moving large balances.

## Withdraw Your ETH

<Steps>
  <Step title="Unwrap WETH, if needed (Blast)">
    WETH can't be bridged directly. If your contract holds WETH, unwrap it to ETH first. Skip this step otherwise.

    | | |
    | - | - |
    | Sent by | Your L2 contract |
    | Contract | **WETH** `0x4300000000000000000000000000000000000004` |
    | Function | `withdraw(uint256 wad)` (selector `0x2e1a7d4d`) |
    | Arguments | `wad`: amount of WETH to unwrap in wei |
    | ETH value | 0 |
  </Step>

  <Step title="Initiate the withdrawal (Blast)">
    | | |
    | - | - |
    | Sent by | Your L2 contract |
    | Contract | **L2BlastBridge** `0x4300000000000000000000000000000000000005` |
    | Function | `bridgeETHTo(address _to, uint32 _minGasLimit, bytes _extraData)` (selector `0xe11013dd`) |
    | Arguments | `_to`: your Ethereum recipient <br /> `_minGasLimit`: `200000` <br /> `_extraData`: `0x` (empty), or an internal reference |
    | ETH value | **The amount of ETH to withdraw**, in wei |

    `_minGasLimit` is the gas available for delivering the ETH to your recipient on Ethereum. `200000` is enough for a plain `receive()`; increase it if your recipient's `receive()` does more work.

    Record these values. The later steps and status checks use them:

    * the **L2 transaction hash**
    * its **L2 block number**
    * the **`withdrawalHash`**: the last field of the `MessagePassed` event emitted by the L2ToL1MessagePasser (`0x4200000000000000000000000000000000000016`) in this transaction
  </Step>

  <Step title="Prove the withdrawal (Ethereum)">
    Wait until the L2 output containing your transaction has been posted to Ethereum, up to \~1 hour (see [Ready to Prove?](#ready-to-prove)). Then call `proveWithdrawalTransaction` on the **OptimismPortal** (`0x0Ec68c5B10F21EFFb74f2A5C61DFe6b08C0Db6Cb`):

    ```solidity theme={null}
    function proveWithdrawalTransaction(
        Types.WithdrawalTransaction memory _tx,
        uint256 _l2OutputIndex,
        Types.OutputRootProof calldata _outputRootProof,
        bytes[] calldata _withdrawalProof
    ) external;
    ```

    The proof arguments are built from your L2 transaction hash. See [Building the Prove and Finalize Transactions](#building-the-prove-and-finalize-transactions) for code that does this.

    Proving also adds your withdrawal to the ETH withdrawal queue and assigns it a `requestId`, which the finalize step needs.
  </Step>

  <Step title="Wait for the challenge period">
    Wait **1 day** after proving.
  </Step>

  <Step title="Finalize the withdrawal (Ethereum)">
    Call `finalizeWithdrawalTransaction` on the **OptimismPortal**:

    ```solidity theme={null}
    function finalizeWithdrawalTransaction(
        uint256 hintId,                        // ETH withdrawal queue checkpoint for your request
        Types.WithdrawalTransaction memory _tx // same _tx as in the prove step
    ) external;
    ```

    <Warning>
      This signature **differs from other OP Stack chains**: Blast's portal takes an extra `hintId` argument before the withdrawal. For ETH, `hintId` identifies the ETH withdrawal queue checkpoint that processed your request: `ETHYieldManager.findCheckpointHint(requestId, 1, ETHYieldManager.getLastCheckpointId())`. A result of `0` means the queue hasn't processed your request yet.
    </Warning>

    <Warning>
      Set the finalize transaction's gas limit explicitly. The portal reverts with `SafeCall: Not enough gas` if the limit is too low. A withdrawal initiated with `_minGasLimit` `200000` needs about 725,000 gas, so use **900,000**.
    </Warning>

    See [Building the Prove and Finalize Transactions](#building-the-prove-and-finalize-transactions) for code that builds and sends this call.

    The ETH is sent to your recipient in the same transaction. Confirm it arrived (see [Delivered?](#delivered)).

    <Note>
      The amount paid out is calculated from the queue checkpoint's share price. It can be slightly less than the amount withdrawn only if the underlying yield had an uncovered loss.
    </Note>
  </Step>
</Steps>

## Building the Prove and Finalize Transactions

The examples below use TypeScript and [viem](https://viem.sh) `2.57.3`. Each builds the transaction from the **L2 transaction hash** of your initiate step and sends it.

### Setup

```typescript theme={null}
import { createPublicClient, createWalletClient, http, parseAbi, type Hash, type Hex } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { blast, mainnet } from 'viem/chains';
import { getWithdrawals, publicActionsL1, publicActionsL2, walletActionsL1 } from 'viem/op-stack';

// Any Ethereum account with ETH for gas can prove and finalize.
const account = privateKeyToAccount(process.env.PRIVATE_KEY as Hex);

const publicClientL1 = createPublicClient({ chain: mainnet, transport: http(process.env.L1_RPC_URL) })
  .extend(publicActionsL1());
const walletClientL1 = createWalletClient({ account, chain: mainnet, transport: http(process.env.L1_RPC_URL) })
  .extend(walletActionsL1());
const publicClientL2 = createPublicClient({ chain: blast, transport: http() })
  .extend(publicActionsL2());
```

### Prove

Run this once the withdrawal is [ready to prove](#ready-to-prove).

```typescript theme={null}
async function prove(l2TxHash: Hash) {
  const receipt = await publicClientL2.getTransactionReceipt({ hash: l2TxHash });
  const [withdrawal] = getWithdrawals(receipt);

  // Prove against the latest L2 output posted to Ethereum. Any output at or after the withdrawal's
  // block works, and public Blast RPCs only serve storage proofs for recent blocks.
  const latestL2Block = await publicClientL1.readContract({
    address: blast.contracts.l2OutputOracle[mainnet.id].address,
    abi: parseAbi(['function latestBlockNumber() view returns (uint256)']),
    functionName: 'latestBlockNumber',
  });
  const output = await publicClientL1.getL2Output({ l2BlockNumber: latestL2Block, targetChain: blast });

  const args = await publicClientL2.buildProveWithdrawal({ output, withdrawal });
  return walletClientL1.proveWithdrawal(args);
}
```

### Finalize

Run this once the [challenge period is over](#challenge-period-over), 1 day after proving. Then [confirm delivery](#delivered).

```typescript theme={null}
async function finalize(l2TxHash: Hash) {
  const receipt = await publicClientL2.getTransactionReceipt({ hash: l2TxHash });
  const [withdrawal] = getWithdrawals(receipt);
  const portal = blast.contracts.portal[mainnet.id].address;

  // ETH is paid out of Blast's ETH withdrawal queue, so the portal needs the queue checkpoint (hintId)
  // for this withdrawal's request. The requestId was assigned when the withdrawal was proven.
  const [, , , requestId] = await publicClientL1.readContract({
    address: portal,
    abi: parseAbi(['function provenWithdrawals(bytes32) view returns (bytes32, uint128, uint128, uint256)']),
    functionName: 'provenWithdrawals',
    args: [withdrawal.withdrawalHash],
  });
  const ethYieldManager = {
    address: '0x98078db053902644191f93988341E31289E1C8FE',
    abi: parseAbi([
      'function getLastCheckpointId() view returns (uint256)',
      'function findCheckpointHint(uint256 requestId, uint256 start, uint256 end) view returns (uint256)',
    ]),
  } as const;
  const lastCheckpointId = await publicClientL1.readContract({ ...ethYieldManager, functionName: 'getLastCheckpointId' });
  const hintId = await publicClientL1.readContract({
    ...ethYieldManager,
    functionName: 'findCheckpointHint',
    args: [requestId, 1n, lastCheckpointId],
  });
  if (hintId === 0n) throw new Error('The ETH withdrawal queue has not processed this withdrawal yet');

  // Blast's portal takes the hintId before the withdrawal, so call it directly instead of using viem's
  // finalizeWithdrawal.
  const finalizeCall = {
    address: portal,
    abi: parseAbi([
      'struct WithdrawalTransaction { uint256 nonce; address sender; address target; uint256 value; uint256 gasLimit; bytes data; }',
      'function finalizeWithdrawalTransaction(uint256 hintId, WithdrawalTransaction _tx)',
    ]),
    functionName: 'finalizeWithdrawalTransaction',
    args: [hintId, withdrawal],
  } as const;

  // The portal reverts with "SafeCall: Not enough gas" if the gas limit is too low. 900,000 is enough for a
  // withdrawal initiated with _minGasLimit 200000; increase it if you used a higher _minGasLimit.
  return walletClientL1.writeContract({ ...finalizeCall, gas: 900_000n });
}
```

## Checking Withdrawal Status

Every stage can be checked with read-only calls on Ethereum, from your own tooling or the **Read as Proxy** tab on Etherscan, using the **L2 block number** and **`withdrawalHash`** you recorded when you initiated.

| Stage | Check | Done when |
| - | - | - |
| Ready to prove | `L2OutputOracle.latestBlockNumber()` | ≥ your L2 block number |
| Proven | `OptimismPortal.provenWithdrawals(withdrawalHash)` | `timestamp` ≠ 0 |
| Challenge period over | proven `timestamp` + `L2OutputOracle.FINALIZATION_PERIOD_SECONDS()` | ≤ the current time |
| ETH queue processed | `ETHYieldManager.getLastFinalizedRequestId()` | ≥ your `requestId` |
| Finalized | `OptimismPortal.finalizedWithdrawals(withdrawalHash)` | `true` |
| Delivered | your recipient's ETH balance | increased by your amount |

### Ready to Prove?

```solidity theme={null}
L2OutputOracle.latestBlockNumber() >= l2BlockNumber
```

### Proven?

```solidity theme={null}
(bytes32 outputRoot, uint128 timestamp, uint128 l2OutputIndex, uint256 requestId)
    = OptimismPortal.provenWithdrawals(withdrawalHash);
```

A `timestamp` of `0` means the withdrawal hasn't been proven. `requestId` is your ETH withdrawal queue request ID.

### Challenge Period Over?

```solidity theme={null}
block.timestamp >= timestamp + L2OutputOracle.FINALIZATION_PERIOD_SECONDS()
```

`timestamp` is the proven timestamp from the previous check. The challenge period is currently 86400 seconds (1 day).

### ETH Queue Processed?

```solidity theme={null}
ETHYieldManager.getLastFinalizedRequestId() >= requestId
```

`requestId` is from [Proven?](#proven). Once this is true, `ETHYieldManager.findCheckpointHint(requestId, 1, ETHYieldManager.getLastCheckpointId())` returns the `hintId` to finalize with.

### Finalized?

```solidity theme={null}
OptimismPortal.finalizedWithdrawals(withdrawalHash) == true
```

This means the finalize transaction has run. It doesn't by itself mean the ETH was delivered: check [Delivered?](#delivered).

### Delivered?

Finalizing hands the withdrawal to the **L1CrossDomainMessenger** (`0x5D4472f31Bd9385709ec61305AFc749F0fA8e9d0`), which calls the L1BlastBridge to send the ETH to your recipient. If that call fails (for example, because your recipient rejects the ETH or runs out of gas), the withdrawal is still marked as finalized, but the messenger records the message as failed and keeps the ETH. Anyone can retry it with `relayMessage` on the L1CrossDomainMessenger, with more gas or after fixing the recipient.

Confirm delivery in any of these ways:

* Your recipient's ETH balance increased by your amount.
* The finalize transaction emitted `ETHBridgeFinalized` from the L1BlastBridge.
* `L1CrossDomainMessenger.successfulMessages(keccak256(data))` is `true`, where `data` is the `data` field of your withdrawal's `MessagePassed` event.

## Contract Addresses

### Blast (Chain ID 81457)

| Contract | Address |
| - | - |
| WETH | `0x4300000000000000000000000000000000000004` |
| L2BlastBridge | `0x4300000000000000000000000000000000000005` |
| L2ToL1MessagePasser | `0x4200000000000000000000000000000000000016` |

### Ethereum (Chain ID 1)

| Contract | Address |
| - | - |
| OptimismPortal | `0x0Ec68c5B10F21EFFb74f2A5C61DFe6b08C0Db6Cb` |
| L2OutputOracle | `0x826D1B0D4111Ad9146Eb8941D7Ca2B6a44215c76` |
| ETHYieldManager | `0x98078db053902644191f93988341E31289E1C8FE` |
| L1BlastBridge | `0x3a05E5d33d7Ab3864D53aaEc93c8301C1Fa49115` |
| L1CrossDomainMessenger | `0x5D4472f31Bd9385709ec61305AFc749F0fA8e9d0` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.