• React
  • Hooks
  • useWatchPendingTransactions

useWatchPendingTransactions

Hook for subscribing to pending transactions in the Provider's transaction mempool.

This is a wrapper around viem's watchPendingTransactions.

import { useWatchPendingTransactions } from 'wagmi'
💡

Only Providers that support the eth_newPendingTransactionFilter method will work with this Hook.

Usage

The listener will be invoked when a new transactions enters the memory pool of the Provider.

import { useWatchPendingTransactions } from 'wagmi'
 
useWatchPendingTransactions({
  listener: (hashes) => console.log(hashes),
})

Configuration

listener

The listener function to be invoked when a new transaction enters the memory pool.

import { useWatchPendingTransactions } from 'wagmi'
 
useWatchPendingTransactions({
  listener: (hashes) => console.log(hashes),
})

chainId (optional)

Force a specific chain id for the request. The wagmi Client's publicClient must be set up as a chain-aware function for this to work correctly.

import { useWatchPendingTransactions } from 'wagmi'
 
useWatchPendingTransactions({
  chainId: 1,
  listener: (hashes) => console.log(hashes),
})

enabled (optional)

Whether or not to enable the listener. Defaults to true.

import { useWatchPendingTransactions } from 'wagmi'
 
useWatchPendingTransactions({
  enabled: false,
  listener: (hashes) => console.log(hashes),
})