[Ethereum] ny way to get pending transaction for specified address

bscfilterspythonweb3.py

is there any way to get pending transaction for a specified address? I can filter them
on bscscan here, but I can't do the same in my web3py code. I can get all pending transaction for current pending block but I can't filter them.
I can do:

txHashPending = w3.eth.filter('latest').get_all_entries()

and I get transactionHashes for pending transactions. I tried doing:

txHashPending = w3.eth.filter({'fromBlock':'pending','toBlock':'pending','from':'0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56'}).get_all_entries()

but it returned already validated/mined transactions.

Best Answer

You could try to get the pending transactions with the 'pending' filter and then iterate over the pending entries. Then you can get the transaction receipt, which contains the 'from' and 'to' attributes.

filter = w3.eth.filter('pending')
new_entries = filter.get_new_entries()

for entry in new_entries:             
    tx = w3.eth.getTransaction(entry)
    if(tx.from == "yourAddress"):
        print("got pending transaction from: ", tx.from)
Related Topic