token.watchCreate
Watches for new TIP20 token creation events on the TIP20 Factory.
Usage
example.ts
import { client } from './viem.config'
const unwatch = client.token.watchCreate({
onTokenCreated: (args, log) => {
console.log('Token:', args.token)
console.log('Token ID:', args.tokenId)
console.log('Name:', args.name)
console.log('Symbol:', args.symbol)
console.log('Currency:', args.currency)
console.log('Quote Token:', args.quoteToken)
console.log('Admin:', args.admin)
},
})
// Later, stop watching
unwatch()Return Type
type ReturnType = () => voidReturns a function to unsubscribe from the event.
Parameters
onTokenCreated
- Type:
function
declare function onTokenCreated(args: Args, log: Log): void
type Args = {
/** Address of the created token */
token: Address
/** ID of the created token */
tokenId: bigint
/** Name of the token */
name: string
/** Symbol of the token */
symbol: string
/** Currency of the token */
currency: string
/** Quote token address */
quoteToken: Address
/** Admin address */
admin: Address
}Callback to invoke when a new TIP20 token is created.
args (optional)
- Type:
object
type Args = {
/** Filter by token address(es) */
token?: Address | Address[] | null
/** Filter by token ID(s) */
tokenId?: bigint | bigint[] | null
}Optional filter arguments to watch for specific tokens.
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.