I am using Etherscan API for various Ethereum details.
I need to find out the
tokens transferred from a token original contract (let's say A) address to a particular address(let's say B).
For this I would need to iterate through all transactions of
B and all the
Event Logs of
A and see if any transaction in
Events matches that of
B if yes then the
data key gives me the value of token transfer.
But I have no way to know these transactions would be part of which block so I would have to iterate through all the blocks, since API supports max of 1000 results in a single call I have no way to know at how many blocks this limit would be reached, so I iterate at steps of
1000, it is painstakingly slow and would take hours.
The API accepts
toBlock parameter. Presently the latest block is at ~4287262 How can I effectively paginate the results, given if I use a step of 1000 for blocks it would take ~4000 calls which seems very ineffective.
One way I optimized is seeing at which block the contract was created this effectively eliminates 95% of the blocks and used multithreading for other blocks but it is still slow.
Any other way/method/suggestion would be great.