Skip to content

buildProveWithdrawal

Builds the transaction that proves a withdrawal was initiated on an L2. Used in the Withdrawal flow.

Usage

example.ts
import { account, publicClientL2, walletClientL1 } from './config'
 
const receipt = await getTransactionReceipt(publicClientL2, {
  hash: '0xbbdd0957a82a057a76b5f093de251635ac4ddc6e2d0c4aa7fbf82d73e4e11039',
})
 
const [withdrawal] = getWithdrawals(receipt)
const output = await walletClientL1.getL2Output({
  l2BlockNumber: receipt.blockNumber,
  targetChain: publicClientL2.chain,
})
 
const args = await publicClientL2.buildProveWithdrawal({ 
  account, 
  output, 
  withdrawal, 
}) 
 
const hash = await walletClientL1.proveWithdrawal(args)

Account Hoisting

If you do not wish to pass an account to every buildProveWithdrawal, you can also hoist the Account on the Wallet Client (see config.ts).

Learn more.

example.ts
import { publicClientL2, walletClientL1 } from './config'
 
const args = await publicClientL2.buildProveWithdrawal({
  output,
  withdrawal,
})
 
const hash = await walletClientL1.proveWithdrawal(args)

Returns

BuildProveWithdrawalReturnType

The parameters required to execute a prove withdrawal transaction.

Parameters

account (optional)

  • Type: Account | Address

The Account to send the transaction from.

Accepts a JSON-RPC Account or Local Account (Private Key, etc).

const args = await client.buildProveWithdrawal({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
  output,
  withdrawal,
})

output

  • Type: GetL2OutputReturnType

The L2 output. Typically provided by getL2Output Action.

const args = await client.buildProveWithdrawal({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  output: { /* ... */ }, 
  withdrawal, 
})

withdrawal

  • Type: Withdrawal

The withdrawal message. Typically provided by getWithdrawals Action.

const args = await client.buildProveWithdrawal({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  output,
  withdrawal: { /* ... */ }, 
})