Skip to content

getL1TokenBalance

Retrieve the token balance held by the contract on L1.

Usage

example.ts
import { account, publicClient } from './config'
 
const balance = await publicClient.getL1TokenBalance({
  account
  token: '0x5C221E77624690fff6dd741493D735a17716c26B',
})

Returns

bigint

Returns the amount of the tokens.

Parameters

account

  • Type: Account | Address

The Account used for check.

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

const balance = await publicClient.getL1TokenBalance({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
  blockTag: 'latest',
  token: '0x5C221E77624690fff6dd741493D735a17716c26B',
})

blockTag (optional)

  • Type: BlockTag | undefined

In which block an balance should be checked on. The latest processed one is the default option.

const balance = await publicClient.getL1TokenBalance({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
  blockTag: 'latest', 
  token: '0x5C221E77624690fff6dd741493D735a17716c26B',
})

token

  • Type: Address

The address of the token.

const balance = await publicClient.getL1TokenBalance({
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
  blockTag: 'latest',
  token: '0x5C221E77624690fff6dd741493D735a17716c26B', 
})