Skip to content

getGame

Retrieves a valid dispute game on an L2 that occurred after a provided L2 block number. Used for the Withdrawal flow.

Usage

example.ts
import { optimism } from 'viem/chains'
import { account, publicClientL1 } from './config'
 
const game = await publicClientL1.getGame({ 
  l2BlockNumber: 69420n, 
  targetChain: optimism, 
}) 

Returns

GetGameReturnType

A valid dispute game.

Parameters

l2BlockNumber

  • Type: bigint

The L2 block number.

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

targetChain

The L2 chain.

const game = await publicClientL1.getGame({
  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.getGame({
  l2BlockNumber,
  disputeGameFactoryAddress: '0xbEb5Fc579115071764c7423A4f12eDde41f106Ed'
})