getGames
Retrieves dispute games for an L2. Used for the Withdrawal flow.
Usage
example.ts
import { optimism } from 'viem/chains'
import { account, publicClientL1 } from './config'
 
const games = await publicClientL1.getGames({ 
  targetChain: optimism, 
}) Returns
GetGamesReturnType
Dispute games.
Parameters
targetChain
- Type: Chain
The L2 chain.
const games = await publicClientL1.getGames({
  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 games = await publicClientL1.getGames({
  l2BlockNumber,
  disputeGameFactoryAddress: '0xbEb5Fc579115071764c7423A4f12eDde41f106Ed'
})l2BlockNumber (optional)
- Type: bigint
The L2 block number.
const games = await publicClientL1.getGames({ 
  l2BlockNumber: 69420n, 
  targetChain: optimism, 
}) limit (optional)
- Type: number
- Default: 100
Limit of games to extract.
const games = await publicClientL1.getGames({ 
  limit: 10, 
  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 games = await publicClientL1.getGames({
  l2BlockNumber,
  portalAddress: '0xbEb5Fc579115071764c7423A4f12eDde41f106Ed'
})
