Skip to content

token.watchApprove

Watches for token approval events on TIP20 tokens.

Usage

example.ts
import { Actions } from 'tempo.ts/wagmi'
import { config } from './wagmi.config'
 
const unwatch = Actions.token.watchApprove(config, {
  token: 0n,
  onApproval: (args, log) => {
    console.log('Amount:', args.amount)
    console.log('Owner:', args.owner)
    console.log('Spender:', args.spender)
  },
})
 
// Later, stop watching
unwatch()

Return Type

type ReturnType = () => void

Returns a function to unsubscribe from the event.

Parameters

onApproval

  • Type: function
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
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
declare function onError(error: Error): void

The 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.