TransWikia.com

How to retrieve the logs of transactions on one contract and multiple addresses

Ethereum Asked by Mohammad Saberi on November 27, 2021

I have an application which should work as an exchange. Customers have their own Ethereum addresses on my Geth server, and they might receive ERC20 Tokens on them. I need to fetch the incoming transaction data for multiple accounts.
I’ve used eth_getLogs() like this:

eth_getLogs(
   '0x9589a2',
   'latest',
   '0xdac17f958d2ee523a2206206994597c13d831ec7',
   [null, null, '0x000000000000000000000000825F80D4c229f56bf1275C9592223a9d921329E2']
);

Now, I have some questions:

  1. What are the 1st and 2nd parameters in array for? I found this sample code and used it, but unfortunately I couldn’t find the appropriate document for it.
  2. I added some 0000… before address regarding to the example I found. It works now, but what is the exact value here and what is its correct format?
  3. And the main question: How can I do searches at once on multiple accounts for each ERC20 Token?

One Answer

You can listen for Transfer events for all tokens. Then build your own database of all transfers you are interested in. Then match those transfers to your exchange user balances.

Poll for the events scan them again a few blocks back.

Here is some Python code: https://github.com/TokenMarketNet/sto/blob/master/sto/ethereum/scanner.py#L153

Answered by Mikko Ohtamaa on November 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP