> For the complete documentation index, see [llms.txt](https://docs.bloxroute.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bloxroute.com/bsc/streams/newtxs-and-pendingtxs/filter.md).

# Filters

You can specify filters when subscribing to **`pendingTx`** and **`newTx`** streams to only receive certain transactions.‌ The filter string uses a SQL-like syntax for logical operations.

This filter dictionary is passed into the **`options`** argument of the **`subscribe()`** call:

```python
ws.subscribe("newTxs", {"filters": "...", ...})
```

### **Available Filters**

**`value`** : Restrict transactions based on their value, denominated in wei. Hex values are also valid.

**`from`** : **Deprecated.** Restrict transactions sender to the specified Ethereum addresses. Requires **`--tx-include-sender-in-feed`** argument. See local gateway [Startup Arguments.](broken://pages/-MlNxudohX6lybndPN4n)

**`to`**: Restrict transactions recepient to the specified Ethereum addresses.

**`gas_price`**, **`max_fee_per_gas`** , **`max_priority_fee_per_gas`** and **`max_fee_per_blob_gas`**: Restrict transactions based on their gas price attributes, denominated in wei. Hex values are also valid.

**`method_id`**: Restrict transactions based on their method ID in the TX input.

**`chain_id`**: Restrict transactions based on their chain ID.

**`gas:`** Restrict transactions based on gas value.

**`type:`** Restrict transactions based on their type.

The SQL-like syntax also supports **`and`** and **`or`** : logical operations.

#### **Examples** <a href="#examples-1" id="examples-1"></a>

{% tabs %}
{% tab title="Value" %}
Filter transactions between 1-4 ETH

```bash
# "filters" Example
"({value} > 1000000000000000000) AND ({value} < 4000000000000000000)"
# wscat Subscribe Example
{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["newTxs", {"include": ["tx_hash"], "filters": "({value} > 1000000000000000000) AND ({value} < 4000000000000000000)"}]}

```

{% endtab %}

{% tab title="Address" %}
Filter transactions with specific to account

```bash
# "filters" Example
"{to} == '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'"
# wscat Subscribe Example
{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["newTxs", {"include": ["tx_hash"], "filters": "{to} == '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'"}]}

```

Filter transactions from two accounts

```bash
# "filters" Example
"({from} IN ['0x6671799F031059e017bBc9E9FCbE6721cc2Bd798',
 '0x09eDBC6ed492C6D4274810E257A690a11d71ce43'])"
# wscat Subscribe Example 
{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["newTxs", {"include": ["tx_hash"], "filters": "({from} IN ['0x6671799F031059e017bBc9E9FCbE6721cc2Bd798', '0x09eDBC6ed492C6D4274810E257A690a11d71ce43'])"}]}
 
```

{% endtab %}

{% tab title="Gas Price" %}
Filter transactions with specific gas price

```bash
# "filters" Example
"({gas_price} > 183000000000)"
# wscat Subscribe Example
{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["newTxs", {"include": ["tx_hash"], "filters": "({gas_price} > 183000000000)"}]}

```

{% endtab %}

{% tab title="Method ID" %}
Filter transactions with specific method ID

```bash
# "filters" Example
"{method_id} == '0xa9059cbb'"
# wscat Subscribe Example
{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["newTxs", {"include": ["tx_hash"], "filters": "{method_id} == '0xa9059cbb'"}]}

```

{% endtab %}
{% endtabs %}

‌Furthermore, logical operations **`and`** and **`or`** may also be used to combine multiple filters. The above examples can be used together as shown in the examples below:

{% tabs %}
{% tab title="Address and Value" %}

```python
# "filters" Example
"{TO} == '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' AND
 ({value} > 4000000000000000000 AND {value} < 5000000000000000000) 
 OR ({from} IN ['0x8fdc5df186c58cdc2c22948beee12b1ae1406c6f',
  '0x77e2b72689fc954c16b37fbcf1b0b1d395a0e288'])"
# wscat Subscribe Example
{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["newTxs", {"include": ["tx_hash"], "filters": "{TO} == '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' AND({value} > 4000000000000000000 AND {value} < 5000000000000000000) OR ({from} IN ['0x8fdc5df186c58cdc2c22948beee12b1ae1406c6f','0x77e2b72689fc954c16b37fbcf1b0b1d395a0e288'])"}]}

```

{% endtab %}

{% tab title="Method ID , Address and Gas Price" %}

```python
# "filters" Example
"{method_id} == '0xa9059cbb' AND
({from} IN ['0x8fdc5df186c58cdc2c22948beee12b1ae1406c6f',
        '0x77e2b72689fc954c16b37fbcf1b0b1d395a0e288']) AND
({gas_price} < 30000000000000000000)"
# wscat Subscribe Example
{"jsonrpc": "2.0", "id": 1, "method": "subscribe", "params": ["newTxs", {"include": ["tx_hash"], "filters": "{method_id} == '0xa9059cbb' AND({from} IN ['0x8fdc5df186c58cdc2c22948beee12b1ae1406c6f', '0x77e2b72689fc954c16b37fbcf1b0b1d395a0e288']) AND ({gas_price} < 30000000000000000000)"}]}

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.bloxroute.com/bsc/streams/newtxs-and-pendingtxs/filter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
