• Core
  • Actions
  • watchPendingTransactions

watchPendingTransactions

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

import { watchPendingTransactions } from '@wagmi/core'
đź’ˇ

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

Usage

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

import { watchPendingTransactions } from '@wagmi/core'
 
const unwatch = watchPendingTransactions({}, (transaction) =>
  console.log(transaction),
)

Return Value

unwatch is a function that can be called to unsubscribe from the pending transactions event.

Configuration

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 { watchPendingTransactions } from '@wagmi/core'
 
const unwatch = watchPendingTransactions(
  {
    chainId: 1,
  },
  (transaction) => console.log(transaction),,
)