accessKey.watchWitness
Watches for key-authorization witness events (KeyAuthorizationWitness), emitted when a key is authorized with a witness (see accessKey.authorize).
Usage
import { client } from './viem.config'
const unwatch = client.accessKey.watchWitness({
onWitness: (args, log) => {
console.log('Witness used:', args)
},
})
// Later, stop watching
unwatch()import { Account, createClient } from 'viem/tempo'
export const client = createClient({
account: Account.fromSecp256k1('0x...'),
})Return Type
type ReturnType = () => voidReturns a function to unsubscribe from the event.
Parameters
onWitness
- Type:
function
declare function onWitness(args: Args, log: Log): void
type Args = {
/** The account that authorized the key. */
account: Address
/** The witness bound to the authorization. */
witness: Hex
}Callback to invoke when a witness is used.
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.