token.watchMint
Watches for token mint events on TIP20 tokens.
Usage
import { } from './viem.config'
const = .token.watchMint({
: '0x20c0000000000000000000000000000000000001',
: (, ) => {
.('To:', .to)
.('Amount:', .amount)
},
})
// Later, stop watching
()Return Type
type ReturnType = () => voidReturns 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): 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.