I'm using web3py to receive new pending transactions. The problem is that i'm only receiving the hash of the transaction, while i would like to get that transaction's data too, such as input, sender and so on. If i use getTransaction and getTransactionReceipt i always get a Transaction with hash xx not found, what else can i use for this?

from web3 import Web3
import asyncio, time
from hexbytes import HexBytes # the read hexabyte data
import web3 as web3
import logging
import requests
import json

Infura_WS = 'PROVIDER'

w3_ws = Web3(Web3.WebsocketProvider(Infura_WS))
w3 = Web3(Web3.HTTPProvider(Infura_HTTP))

async def handle_event(event):
    txHash = HexBytes.hex(event)

        print(txHash, w3.eth.getTransactionReceipt(txHash))

    except Exception as e:
        print('Error in handle_event', e)

async def log_loop(event_filter, poll_interval):
    while True:
            for event in event_filter.get_new_entries():
                await handle_event(event)
            await asyncio.sleep(poll_interval)
        except Exception as e:

def main():
    global loop
    block_filter = w3_ws.eth.filter('pending')
    loop = asyncio.get_event_loop()

                log_loop(block_filter, 2)))

if __name__ == '__main__':

2 Answers 2


By definition, transaction receipts can be only available after the transaction is mined and the state transition is complete. Because until the transaction is mined, you do not know if it is rejected or not.

So what you are asking is impossible.

  • Thanks. So if i can't get the receipt, how can i at least know some data about the tx, such as the input, or who sent it and such?
    – JayK23
    Nov 22, 2021 at 9:23
  • If i open any contract on etherscan, it will show all the pending transactions for that contract, and even if the tx is still pending, i can see everything about it etherscan.io/address/0x7a250d5630b4cf539739df2c5dacb4c659f2488d
    – JayK23
    Nov 22, 2021 at 9:24
  • eth_getTransaction RPC gives all the info you can have web3py.readthedocs.io/en/stable/… Nov 22, 2021 at 9:26
  • Thanks, but i'm not sure i have to use getTransaction here. Every time i receive a new hash from the code above and i use getTransaction(hash) i get an 'hash not found' error
    – JayK23
    Nov 22, 2021 at 9:29
  • 1
    If you see the transaction hash in Etherscan, but cannot get information from Infura I suggest you contact Infura support or switch to some other working node provider, your run your own node: ethereumnodes.com Nov 22, 2021 at 10:25

Use get_block with full transactions.

pendingBlock = w3.eth.get_block('pending', full_transactions=True)

This will show all transactions in the pending block, with full TX data. (from, to, gas info, input data, value etc).

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.