Watch and Sync events unconfirmed/confirmed behaviour

I would like to clarify the expected behaviour for unconfirmed and confirmed transactions in Moralis that are synced using the sync contract events.
If I understand correctly, as soon as the transaction is mined, it is written to the table with confirmed = false. After a while, once the transaction is confirmed, the confirmed is updated to true. For 99% of all transactions this will probably work this way, now I want to clarify 2 edge cases:

  1. Original transaction is uncled and gets placed into another block
    what happens here? Is a second entry written to the table which will be confirmed later, leaving me with a confirmed and unconfirmed entry? Or when the transaction is confirmed will the information (e.g., block timestmap, tx index, etc) be overwritten by the confirmed values and I will have one confirmed entry?

  2. Original (successful) transaction is uncled and confirmed transaction failed (for example I make a buy on uniswap, the buy goes through initially, tx gets uncled, another transaction is placed before mine making my transaction fail due to slippage)
    Will I be left with an unconfirmed entry in the database (because with the failed transaction, no events will be emitted) or will the entry be deleted from the database?

I know that these are exceptionally rare edge cases but still, I feel like this is quite important to keep in mind and the documentation doesnโ€™t go to deep into this topic

The second case seems easier, my assumption is that the transaction will remain as unconfirmed

Iโ€™m not too sure on the first case.
There is also another more rare case when a transaction gets confirmed and then a reorg happens and the transaction is moved to another block or it fails.

The case you mention should be exceptionally rare as 12 confirmations achieve 99.99% confirmation. So nothing I would worry about too much. Also proof of stake networks have a 100% confirmation so after the merge (or for other pos networks like polygon) this shouldnโ€™t be a real issue as well.

1 Like