Skip to content

buildMigratedWithdrawal

Reconstructs the Bedrock Withdrawal for a withdrawal that was initiated before the Tectonic upgrade (V1/OVM) and migrated into the Bedrock L2ToL1MessagePasser during the upgrade.

These migrated withdrawals were written into the new message passer's storage by state surgery and never emitted a Bedrock MessagePassed event, so getWithdrawals cannot recover them from the original receipt. This action rebuilds the withdrawal struct so it can be passed to buildProveWithdrawal — and to getWithdrawalStatus (via its withdrawal parameter) so the status can be resolved too. Used in the Withdrawal flow for legacy withdrawals.

Usage

example.ts
import {
  account,
  publicClientL1,
  publicClientL2,
  walletClientL1,
} from './config'
 
// A pre-Tectonic (V1/OVM) withdrawal transaction hash.
const withdrawal = await publicClientL2.buildMigratedWithdrawal({ 
  legacyTxHash:
    '0xa1145ceb00b7e25091f5cb6ed18235a6893f7998e692aba3fcfecb6e4431ea76', 
}) 
 
const output = await publicClientL1.getL2Output({
  // For migrated withdrawals the original legacy L2 block isn't needed: the
  // slot exists from the Bedrock migration onward, so the latest output covers it.
  l2BlockNumber: 0n,
  targetChain: publicClientL2.chain,
})
 
const args = await publicClientL2.buildProveWithdrawal({
  account,
  output,
  withdrawal,
})
const hash = await walletClientL1.proveWithdrawal(args)

Returns

Withdrawal

The reconstructed Bedrock withdrawal, ready to pass to buildProveWithdrawal.

Parameters

legacyTxHash

  • Type: Hash

Hash of the original (pre-Tectonic) L2 withdrawal transaction.

const withdrawal = await publicClientL2.buildMigratedWithdrawal({
  legacyTxHash:
    '0xa1145ceb00b7e25091f5cb6ed18235a6893f7998e692aba3fcfecb6e4431ea76', 
})

l1CrossDomainMessengerAddress (optional)

  • Type: Address
  • Default: client.chain.contracts.l1CrossDomainMessenger[sourceId].address

The L1CrossDomainMessenger address (the migrated withdrawal's target). Defaults to the address configured on the client's chain.

const withdrawal = await publicClientL2.buildMigratedWithdrawal({
  legacyTxHash: '0xa114...',
  l1CrossDomainMessengerAddress: '0x676A795fe6E43C17c668de16730c3F690FEB7120', 
})