[Ethereum] way to get the logs for all transactions in a block

erc-20logsmonitoringparity

I am building a system that monitors ERC20 token deposits to a large number of ethereum addresses (1-4 million). While I have not tried, I do not think that the parity clients would be able to support such a large amount of filters. I intend to build a customised data structure in order to achieve this task. Therefore, I would like to acquire the logs of all transactions in a block. Is there a way to do so?

This question is related to How to programmatically detect and accept ETH and ERC20 deposits

However, answers to the above post have not adequately addressed my concern about scalability.


What I have tried:

I am currently scanning the whole block for transaction hashes and then using eth_getTransactionReceipt to acquire the logs for each transaction. The pseudocode is as follows:

@parallel
for block in all blocks:
  all_tx = get_all_txs(block);
  for tx in all_tx:
    save_in_db(eth_getTransactionReceipt(tx).getlogs())

I am wondering if there is a better way to retrieve the logs, perhaps retrieving all logs at once?

Best Answer

See eth_getLogs: https://github.com/paritytech/parity/wiki/JSONRPC-eth-module#eth_getlogs

There you have possibility to filter only logs from ERC20 using topics.

Related Topic