Skip to content

token.watchMint

Watches for token mint events on TIP20 tokens.

Usage

example.ts
import { Actions } from 'tempo.ts/wagmi'
import { config } from './wagmi.config'
 
const unwatch = Actions.token.watchMint(config, {
  token: '0x20c0000000000000000000000000000000000001',
  onMint: (args, log) => {
    console.log('To:', args.to)
    console.log('Amount:', args.amount)
  },
})
 
// Later, stop watching
unwatch()

Return Type

type ReturnType = () => void

Returns a function to unsubscribe from the event.

Parameters

onMint

  • Type: function
declare function onMint(args: Args, log: Log): void
 
type Args = {
  /** Address that received the tokens */
  to: Address
  /** Amount minted */
  amount: bigint
}

Callback to invoke when tokens are minted.

token

  • Type: Address | bigint

Address or ID of the TIP20 token to watch.

args (optional)

  • Type: object
type Args = {
  /** Filter by recipient address */
  to?: 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.