0

I am using the URL "https://mainnet.infura.io/v3/key". But I can't get a pending transaction. This is my code.

pendingTransaction = web3.eth.filter('pending')

I had an error like this.

The method eth_newPendingTransactionFilter does not exist/is not available.

What reason this error?

2 Answers 2

1

You cannot get pending transactions using the standard Infura endpoint. I recommend to use chainstack.com, it's free and it works.

Then you can use web3.py to get the pending transactions. I have a repo about this here if you want to check it out. But the main code is this:

# retrive pending transactions hash
pending_tx_filter = web3.eth.filter('pending')
pending_tx = pending_tx_filter.get_new_entries()     

# loop through the list of transcations and displays the tx hash
for hash in pending_tx:
    print('Hash of a Pending Transaction:' , web3.toHex(hash))
0

Infura does not provide stateful API methods, like creating filters. A filter would need to maintain a state on the server side.

Depending on the use case

2
  • Thank you for your reply. I received a result like this. Filter for 0x6820. Could you get transaction data from this data?
    – Alex Weber
    Commented Jun 19, 2021 at 8:42
  • See get_new_entries and get_all_entries web3py.readthedocs.io/en/stable/… Commented Jun 19, 2021 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.