• Core
  • Actions
  • watchPendingTransactions

watchPendingTransactions

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

This is a wrapper around viem's watchPendingTransactions.

import { watchPendingTransactions } from '@wagmi/core'
💡

Only RPC 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 RPC Provider.

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

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 publicClient 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),,
)