nonce.watchActiveKeyCountChanged
Watches for active key count changed events. This event is emitted when an account starts using a new nonce key for the first time.
Usage
example.ts
import { client } from './viem.config'
const unwatch = client.nonce.watchActiveKeyCountChanged({
onActiveKeyCountChanged: (args, log) => {
console.log('Account:', args.account)
console.log('New active key count:', args.newCount)
},
})
// Later, stop watching
unwatch()Return Type
type ReturnType = () => voidReturns a function to unsubscribe from the event.
Parameters
onActiveKeyCountChanged
- Type:
function
declare function onActiveKeyCountChanged(args: Args, log: Log): void
type Args = {
/** Address of the account */
account: Address
/** New count of active nonce keys */
newCount: bigint
}Callback to invoke when the active key count changes.
args (optional)
- Type:
object
type Args = {
/** Address of the account to filter by */
account?: Address | Address[] | null
}Optional filters for the event.
fromBlock (optional)
- Type:
bigint
Block to start listening from.
onError (optional)
- Type:
function
declare function onError(error: Error): voidThe callback to call when an error occurred when trying to get for a new block.
poll (optional)
- Type:
true
Whether to use polling.
pollingInterval (optional)
- Type:
number
Polling frequency (in ms). Defaults to Client's pollingInterval config.