1

After studying about solidity events, my understanding is that receiving an event doesn’t guarantees that the transaction is final. Transaction may yet to be included into the block. And even if it gets included in the block, it can get removed later on because of an uncle block.

I also read that Exchanges usually use some N block confirmation or even more, to make sure transaction is irreversible.

My questions are :

  1. How can I implement a N block confirmation in dapp design and make it foolproof.

  2. Consider a case wherein we need to add/update data in an off-chain base based on events, then how and when should we decide that transaction has been written to the blockchain and we can commit data to the off-chain database ?

  3. How to handle case if the block containing the transaction has become an Uncle Block? Again how and when to update the off chain data.

I am curios to know how production grade dapps which run on main net handle these scenarios and maintain data integrity in case they have any logic which depends on events.

  • Your understanding is incorrect. Once the transaction is mined, events emitted during the execution of the EVM are stored in Receipts and the hash of the Receipts is included in the block header, making them unremovable from blockchain data – Nulik Aug 29 '18 at 18:59
  • Transactions in Uncle blocks are ignored. – Nulik Aug 29 '18 at 19:00
  • You are complicating your life a lot, if you receive an event, it is final. However, you have to wait for enough block confirmations. If you don't, a chain split can remove past events with the new ones, however your app will receive them again so, you aren't going to lose anything. – Nulik Aug 29 '18 at 19:02
  • @Nulik, will appreciate if can you please let me know how we can code a logic which waits for N blocks and after confirmation takes some action in the dApp. – tanmay Aug 30 '18 at 3:10
  • are you going to get events for 1 contract or for many contracts? – Nulik Aug 30 '18 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.