token.watchApprove
Watches for token approval events on TIP20 tokens.
Usage
ts
import { } from 'wagmi/tempo'
import { } from './config'
const = ..(, {
: 0n,
(, ) {
.('args:', )
},
})
// Later, stop watching
()ts
import { createConfig, http } from 'wagmi'
import { tempoTestnet } from 'wagmi/chains'
import { KeyManager, webAuthn } from 'wagmi/tempo'
export const config = createConfig({
connectors: [
webAuthn({
keyManager: KeyManager.localStorage(),
}),
],
chains: [tempoTestnet],
multiInjectedProviderDiscovery: false,
transports: {
[tempoTestnet.id]: http(),
},
})Return Type
() => void
Returns a function to unsubscribe from the event.
Parameters
onApproval
- Type:
function
ts
declare function onApproval(args: Args, log: Log): void
type Args = {
/** Amount approved */
amount: bigint
/** Address of the token owner */
owner: Address
/** Address of the spender */
spender: Address
}Callback to invoke when tokens are approved.
token
- Type:
Address | bigint
Address or ID of the TIP20 token to watch.
args (optional)
- Type:
object
ts
type Args = {
/** Filter by token owner address */
owner?: Address | Address[] | null
/** Filter by spender address */
spender?: Address | Address[] | null
}Filter events by owner and/or spender addresses.
fromBlock (optional)
- Type:
bigint
Block to start listening from.
onError (optional)
- Type:
function
ts
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
Enable polling mode.
pollingInterval (optional)
- Type:
number
Polling frequency (in ms). Defaults to Client's pollingInterval config.