Search code examples
pythonethereumweb3py

Get transaction from ethereum blockchain via Web3


I would like to extract the information about ethereum transaction to e.g. find out whether the transaction occur on Uniswap.

As indicated here, I tried get_transaction, and all what it can return me is the error TransactionNotFound: Transaction with hash: 'xxxxx' not found.

I run this command, with the transaction hash from previously mentioned page, to run it (w3 is an instance of Web3 w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:8545'))):

w3.eth.get_transaction('0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060')

It gives me the same error.

I tried e.g. w3.eth.get_block(555555), which works.


Solution

  • are you using local node? i think your code must be like this:

    web3 = Web3(Web3.HTTPProvider("https://bsc-dataseed.binance.org/"))