Skip to content

token.watchMint

Watches for token mint events on TIP20 tokens.

Usage

ts
import {  } from 'wagmi/tempo'
import {  } from './config'

const  = ..(, {
  : '0x20c0000000000000000000000000000000000001',
  (, ) {
    .('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

onMint

  • Type: function
ts
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
ts
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
ts
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

Enable polling mode.

pollingInterval (optional)

  • Type: number

Polling frequency (in ms). Defaults to Client's pollingInterval config.

Viem

Released under the MIT License.