Skip to content
LogoLogo

accessKey.getRemainingLimit

Gets the remaining spending limit for a key-token pair.

Usage

import { client } from './viem.config'
 
const { remaining, periodEnd } = await client.accessKey.getRemainingLimit({
  account: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
  accessKey: '0x1234567890abcdef1234567890abcdef12345678',
  token: '0x20c0000000000000000000000000000000000000',
})
 
console.log('Remaining limit:', remaining)
console.log('Period end:', periodEnd)
Remaining limit: 1000000n
Period end: 1712345678n

Return Type

type ReturnType = {
  remaining: bigint
  periodEnd: bigint | undefined
}

The remaining spending amount and period end timestamp.

periodEnd is undefined on pre-T3 chains.

Parameters

accessKey

  • Type: Address | AccessKeyAccount

The access key address or account.

account

  • Type: Address | Account

Account address.

token

  • Type: Address

The token address.

blockNumber (optional)

  • Type: bigint

Block number to read the state from.

blockOverrides (optional)

  • Type: BlockOverrides

Block overrides to apply to the state.

blockTag (optional)

  • Type: BlockTag

Block tag to read the state from.

stateOverride (optional)

  • Type: StateOverride

State override to apply.