Python + getting pending transactions


I’m having trouble getting pending txs using

when I type w3.eth.filter(‘pending’), I get “ValueError: {‘code’: -32601, ‘message’: ‘The method eth_newPendingTransactionFilter does not exist/is not available’}”

I have set project id and api key in env variables.
Can you help me?

Hi @redtaber - welcome to the Infura community!

Can you send over the block of code you’re working with? You can check out the web3py docs to get more information about the eth_newPendingTransactionFilter); it sounds like it may be an issue with how you’re using the w3.eth.filter('pending') and the method eth_newPendingTransactionFilter, but without seeing your code, it’s difficult to tell for sure.

The code fails on the filter creation. So I’m getting the error even with a basic code like this:

import os
from import w3

os.environ[‘WEB3_INFURA_PROJECT_ID’] = ‘…’
os.environ[‘WEB3_INFURA_API_KEY’] = ‘…’

def main():
eth_filter = w3.eth.filter(‘pending’) # this is the place where it fails
pending_txs = eth_filter.get_all_entries()

if name == ‘main’:

Hi @redtaber - we don’t actually support the eth_newPendingTransactionFilter method.

So there is no way to get pending transactions using python?

You should be able to subscribe to our WSS and use the newPendingTransactions request param. This will return the hash for all transactions in the pending state. If you’d like more information, you can reference the docs here.