Is it possible to filter Ethereum pendingTransactions?

Viewed 2780

To get a list of the pending transactions that my node is aware of I can easily call the eth_pendingTransactions jRPC call. This will give a big list of pending transactions, which all need parsing to find the pending transactions I care about by the client.

Is it possible pre-filter the transactions? Would eth_newpendingtransactionfilter be any help https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newpendingtransactionfilter ? I can't seem to understand how this is related to pending transactions.

1 Answers

Ok, I did a bit more digging and I've found my answers.

  • eth_pendingTransactions can not be filtered.
  • eth_newpendingtransactionfilter doesn't filter anything, it instead subscribes the client to receive events when a new pending transaction enters the transaction pool.

However there is a JSON_RPC method in the OpenEthereum implementation of an Ethereum node that allows for filtering of pendingTransactions.

parity_pendingtransactions

Example:

{
  "jsonrpc":"2.0",
  "method":"parity_pendingTransactions",
  "params":[
    null,
    {
      "to": { "eq": "0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6" }
    }
  ],
  "id":1
}

Obviously this means running an OpenEthereum node.

Related