Skip to content

waitForNextGame

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

Internally calls getTimeToNextGame and waits the returned seconds.

Usage

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

Returns

waitForNextGameReturnType

The dispute game.

Parameters

l2BlockNumber

  • Type: bigint

The L2 block number.

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

targetChain

The L2 chain.

const game = await publicClientL1.waitForNextGame({
  l2BlockNumber,
  targetChain: optimism, 
})

disputeGameFactoryAddress (optional)

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

The address of the DisputeGameFactory contract. Defaults to the DisputeGameFactory contract specified on the targetChain.

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

const game = await publicClientL1.waitForNextGame({
  l2BlockNumber,
  disputeGameFactoryAddress: '0xbEb5Fc579115071764c7423A4f12eDde41f106Ed'
})

intervalBuffer (optional)

  • Type: number
  • Default: 1.1

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

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

portalAddress (optional)

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

The address of the Portal contract. Defaults to the Portal contract specified on the targetChain.

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

const game = await publicClientL1.waitForNextGame({
  l2BlockNumber,
  portalAddress: '0xbEb5Fc579115071764c7423A4f12eDde41f106Ed'
})