I would like to see the real-time pending transactions in the Ethereum txpool via Web3.py. I do not run a local node but use Infura instead.
According to the documentation of Web3.py, apparently one has three different options:
Option 1 is not viable as the API does not seem to support Infura node. Thus I tried option 2 & 3 and they give me two different sets of pending transactions. Does anyone know why it is the case? Do the two methods retrieve different pending transactions? Thanks!
Option 2 :
pending_block= w3.eth.getBlock(block_identifier='pending', full_transactions=True)
pending_transactions= pending_block.['transactions']
Option 3 :
pending_transactions_filter= w3.eth.filter('pending')
pending_transactions= pending_transactions_filter.get_new_entries()
These are different transaction sets fundamentally as it seems Option 2 just filters on a pending block, but Option 3 includes even more pending transactions that are not even in a pending block. This is evident to me because Option 2 allows you to get full tx content/info, but Option 3 only gives me the txhash IDs, many of which cannot be looked up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With