3

Say one smart contract trigers an event after one transaction. if this transaction was recorded in one uncle block, then there will be one event, and after confirmed by main block , will there be another event?

let 's say we have a web3 front end watching this contract, how many events will be recorded.

3

If your frontend observes the event logs via JSON RPC (method eth_newFilter to create a filter and method eth_getFilterChanges to poll for the subsequent changes), you have the ability to receive events either from mined transactions (included into mined blocks), or from pending (not yet mined) transactions.

Even if you receive only events from mined transactions, there is a possibility that the block that was mined would later become an uncle due to chain reorganization. According to the eth_getFilterChanges documentation, in that case you will receive log records again with a removed tag.

This essentially means that you should only take an action on an event if this action could later be compensated in your system (in case an event with the removed tag comes later), or you should wait a certain amount of time before taking this action, to make sure the event won't be rolled back.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.