Skip to content

token.watchMint

Watches for token mint events on TIP20 tokens.

Usage

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

const unwatch = Actions.token.watchMint(config, {
  token: '0x20c0000000000000000000000000000000000001',
  onMint(args, log) {
    console.log('args:', args)
  },
})

// Later, stop watching
unwatch()
ts
import { createConfig, http } from 'wagmi'
import { tempo } from 'wagmi/chains'
import { tempoWallet } from 'wagmi/tempo'

export const config = createConfig({
  connectors: [tempoWallet()],
  chains: [tempo],
  multiInjectedProviderDiscovery: false,
  transports: {
    [tempo.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.