My application having the needs to detect newest transaction from a EOA, and I am going to use https://etherscan.io's API. To reduce transaction scanning, I decides to recording the last block number of EOA's transaction API calling, but I wondering will this method losing some later transactions.

So I post this question for helping, is this processing will works or how should I do to avoiding repeats transaction scanning ?

1 Answer 1


Unfortunately you cannot simply use the block number to do this because of something called 'blockchain reorganization'. I encourage you to Google this and read about it. Here are some links:

How should I handle blockchain forks in my DApp?

Syncing events on Database - Dealing with blockchain reorganization

How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?


If two miners mine a block at the same time, there will be 2 blocks A and B with the same block number but with a different block hash. These blocks might not have the exact same set of transactions.

If you received block A first and process its transactions, but then another miner mines block C on top of B, block A will be reversed entirely and you will have to un-process its transactions and replace them with B & C.

The end of the blockchain would look like this:

        ___ A
       /  0xa7bcc8..
      \   15788          15789
       \___ B ------------ C
          0x78dd13..     0x919cc3..

Using your method, you would process block A and then block C. You will now process duplicate transactions that are in both A and C, and you will miss transactions that are only in block B.

I hope this helps you understand the problem and why you can't just simply remember the last block number you've processed. You will have to look at the block hashes and implement code that un-processes transactions if a blockchain reorganization is detected.

If you do not want to implement code that un-processes transactions, you can instead only process a block if ~10 other blocks have been mined on top of it. You will have to rely on no blockchain-reorganizations of more than 10 blocks happening. I would still recommend that you implement code that detects such a large blockchain-reorganization and prevents your system from doing wrong things.

  • I have an another question that will some transactions going disappeared if block reorganization happening? I am doing with ethereum not so long, where can I get more information about block reorganize?
    – zKF53064
    Commented Dec 18, 2018 at 3:05
  • @zKF53064 Yes, transactions that were in A might not be in B or C at all. There's isn't a lot of documentation about blockchain reorganization, because it logically follows from the way blockchains and mining works.
    – Jesbus
    Commented Dec 18, 2018 at 7:48

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.