Skip to content
LogoLogo

token.watchBurn

Watches for token burn events on TIP20 tokens.

Usage

import {  } from './viem.config'
 
const  = .token.watchBurn({
  : 1n, // or token address
  : (, ) => {
    .('Amount:', .amount)
    .('From:', .from)
  },
})
 
// Later, stop watching
()

Return Type

type ReturnType = () => void

Returns a function to unsubscribe from the event.

Parameters

onBurn

  • Type: function
declare function onBurn(args: Args, log: Log): void
 
type Args = {
  /** Address whose tokens were burned */
  from: Address
  /** Amount burned */
  amount: bigint
}

Callback to invoke when tokens are burned.

token

  • Type: Address | bigint

Address or ID of the TIP20 token.

args (optional)

  • Type: object
type Args = {
  /** Filter by burner address */
  from?: Address | Address[] | null
}

Optional filter arguments.

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.