token.watchBurn
Watches for token burn events on TIP20 tokens.
Usage
example.ts
import { client } from './viem.config'
const unwatch = client.token.watchBurn({
token: 1n, // or token address
onBurn: (args, log) => {
console.log('Amount:', args.amount)
console.log('From:', args.from)
},
})
// Later, stop watching
unwatch()Return Type
type ReturnType = () => voidReturns 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): 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.