nonce.getNonce
Gets the nonce for an account and nonce key. This is useful for managing multiple nonce lanes for parallel transaction submission.
Usage
example.ts
import { client } from './viem.config'
const nonce = await client.nonce.getNonce({
account: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
nonceKey: 1n,
})
console.log('Nonce:', nonce)
Nonce: 42nReturn Type
type ReturnType = bigintThe current nonce value for the given account and nonce key.
Parameters
account
- Type:
Address
Account address to get the nonce for.
nonceKey
- Type:
bigint
Nonce key (must be > 0, key 0 is reserved for protocol nonces).
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.