evmTracker()
evmTracker(
params):Promise<void>
Defined in: trackers/evmTracker.ts:178
Tracks a standard EVM transaction by its hash, without a store. Use it to track transactions in your own state or on a server.
Steps (all RPC calls go through the wagmi client of tx.chainId):
- Calls
onInitialize. Fails at once for the zero hash or when there is no client for the chain. - Calls
getTransactionup toretryCounttimes,retryTimeoutms apart, so a transaction the node has not indexed yet is still found; then callsonTxDetailsFetched. - Waits for the receipt with
waitForTransactionReceipt, retrying up to 5 times (5, 10, 15, 20 and 25 s apart) when isRetryableReceiptError matches. If viem reports a replacement, callsonReplacedand stops. - If
requiredConfirmationsis above 1, pollsgetTransactionConfirmationsevery 5 s until it is reached. - Awaits
onSuccess, also for reverted transactions.
Any other error, including one thrown by onSuccess, is passed to onFailure.
Parameters
params
The transaction, the wagmi config and the callbacks.
Returns
Promise<void>
A promise that resolves when tracking has finished.
Example
await evmTracker({
config: wagmiConfig,
tx: { txKey: hash, chainId: 1, requiredConfirmations: 2 },
onTxDetailsFetched: (details) => console.log('Nonce', details.nonce),
onSuccess: async (_details, receipt) => console.log('Mined with status', receipt.status),
onReplaced: (replacement) => console.log('Replaced by', replacement.transaction.hash),
onFailure: (error) => console.error('Tracking failed', error),
});Last updated on