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?
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?
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.
web3pyInstead, you can use indexing services, such as Etherscan.
As explained in API docs, you can then query for transaction history in the following way:
https://api.etherscan.io/api?module=account&action=txlist&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&startblock=0&endblock=99999999&page=1&offset=10&sort=asc&apikey=YourApiKeyToken
web3pyIf 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:
https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.getTransaction
https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.getBlock
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 '22 at 09:28
web3.py. The tagging saysweb3.js. – goodvibration Oct 12 '20 at 09:37