Skip to content

waitForNextL2Output

Waits for the next L2 output (after the provided block number) to be submitted. Used within the waitToProve Action.

Internally calls getTimeToNextL2Output and waits the returned seconds.

Usage

example.ts
import { account, publicClientL1, publicClientL2 } from './config'
 
const l2BlockNumber = await publicClientL2.getBlockNumber()
const output = await publicClientL1.waitForNextL2Output({ 
  l2BlockNumber, 
  targetChain: publicClientL2.chain, 
}) 

Returns

WaitForNextL2OutputReturnType

The L2 output proposal.

Parameters

l2BlockNumber

  • Type: bigint

The L2 block number.

const output = await publicClientL1.waitForNextL2Output({ 
  l2BlockNumber: 69420n, 
  targetChain: optimism, 
}) 

targetChain

The L2 chain.

const output = await publicClientL1.waitForNextL2Output({
  l2BlockNumber,
  targetChain: optimism, 
})

intervalBuffer (optional)

  • Type: number
  • Default: 1.1

The buffer to account for discrepencies between non-deterministic time intervals.

const output = await publicClientL1.waitForNextL2Output({
  intervalBuffer: 1.2, 
  l2BlockNumber,
  targetChain: optimism, 
}) 

l2OutputOracleAddress (optional)

  • Type: Address
  • Default: targetChain.contracts.l2OutputOracle[chainId].address

The address of the L2 Output Oracle contract. Defaults to the L2 Output Oracle contract specified on the targetChain.

If a l2OutputOracleAddress is provided, the targetChain parameter becomes optional.

const output = await publicClientL1.waitForNextL2Output({
  l2BlockNumber,
  l2OutputOracleAddress: '0xbEb5Fc579115071764c7423A4f12eDde41f106Ed'
})