I really don't know how to get a list of transactions history about specific contract address using web3.py

and I use Infura HTTPProvider

I just have only one 'contract address'.

Can i get information about this contract address using web3.py?

  • The question says web3.py. The tagging says web3.js. Oct 12, 2020 at 9:37

1 Answer 1


Getting all transaction history requires you to iterate over each and every block since the contract creation. As you might guess, this would be extremely slow, plus it depends on your Infura plan: rate limits and number of historical blocks available.

Faster Solution without web3py

Instead, you can use indexing services, such as Etherscan.

As explained in API docs, you can then query for transaction history in the following way:


Slower solution with web3py

If your Infura plan allows it, you can iterate over blocks and get block details using eth_getBlockByNumber JSON-RPC method. In web3py, it is equivalent to web3.eth.getBlock(blocknumber). Then you would iterate over transaction hashes using web3.eth.getTransaction(txhash) and check for from/to address against your contract address. See:



  • 3
    account is not contract. This gives you the list of transactions for an account, not the list of all transaction with a smart contract.
    – shredding
    Apr 10, 2022 at 9:28

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.