• React
  • Hooks
  • useWatchPendingTransactions

useWatchPendingTransactions

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

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: (transaction) => console.log(transaction),
})

Configuration

listener

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

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

chainId (optional)

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

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

enabled (optional)

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

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