> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# eth_subscribe ("newPendingTransactions") | Avalanche

> Subscribe to pending Avalanche transactions via WebSocket. Receive real-time notifications when new unconfirmed transactions enter the mempool.

Note that because the Avalanche mempool is [only accessible to validators](/docs/mempool-configuration), this method will only return transactions that were submitted through the same node you are connected to.

<Check>
  ### Get your own node endpoint today

  [Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required.

  You can sign up with your GitHub, X, Google, or Microsoft account.
</Check>

## Parameters

* To subscribe to transaction hashes only —`newPendingTransactions`.
* To subscribe to full transaction bodies — `"newPendingTransactions", true`

## Response

* `subscription` — the subscription ID.
* `string `— the hash of a pending transaction.

## `eth_subscribe("newPendingTransactions")` code examples

<Info>
  Note that subscriptions require a WebSocket connection and [WebSocket cat](https://www.npmjs.com/package/wscat) for you to use this method in the console.

  Install WebSocket cat with:

  `npm install -g wscat`
</Info>

<CodeGroup>
  ```shell wscat theme={"system"}
  $ wscat -c YOUR_CHAINSTACK_WEBSOCKET_ENDPOINT
  # Wait for the connection to be established

  Connected (press CTRL+C to quit)

  > {"id":1,"jsonrpc":"2.0","method":"eth_subscribe","params":["newPendingTransactions", true]}
  ```

  ```javascript javascript theme={"system"}
  const WebSocket = require('ws');

  const webSocket = new WebSocket('CHAINSTACK_WSS_URL');

  async function subscribeToNewPendingTransactions() {

    const request = {
      id: 1,
      jsonrpc: '2.0',
      method: 'eth_subscribe',
      params: ['newPendingTransactions', true],
    };

    const onOpen = (event) => {
      webSocket.send(JSON.stringify(request));
    };

    const onMessage = (event) => {
      const response = JSON.parse(event.data);
      console.log(response);
    };

    try {
      webSocket.addEventListener('open', onOpen);
      webSocket.addEventListener('message', onMessage);
    } catch (error) {
      console.error(error);
    }
  }

  subscribeToNewPendingTransactions();
  ```
</CodeGroup>

This will generate a continuous stream of data displaying new pending transactions as they are added to the mempool.

Use [eth\_unsubscribe](/reference/avalanche-native-unsubscribe) to remove the subscription.

## Use case

The `eth_subscribe("newPendingTransactions")` method on Avalanche is used to subscribe to the network and receive real-time updates on all new pending transactions on the network. This can be useful in a variety of real-world scenarios, including:

* Trading applications. A trading application can use this method to keep track of any new transactions that are being made on the network. This can be particularly useful for high-frequency trading, where speed is crucial. By subscribing to this method, the trading application can receive real-time updates on new trades, allowing it to quickly respond and execute trades.

* Monitoring tools. Monitoring tools can use this method to keep track of any suspicious activity on the network. By subscribing to this method, monitoring tools can receive real-time updates on any new pending transactions and quickly take action if necessary.

* Payment processors. Payment processors can use the `eth_subscribe("newPendingTransactions")` method to monitor incoming transactions from their customers. This can be particularly useful for businesses that rely on blockchain technology to process payments, as it allows them to track incoming payments in real time. By subscribing to this method, payment processors can receive instant notifications when new payments are received, which can help streamline their payment processing workflows.
