0

I have a transaction method call which sets a value and at the end I have emitted an event. Somewhere in web3 I am listening an events.

What if the transaction took time to mine?

Does event get emitted immediately or it will wait until transaction is mined?

1

Once you have created a transaction, you broadcast it to the network and wait for a miner to include it in their block. Meanwhile, from the point of view of all external parties, the transaction hasn't yet happened.

Once a transaction is included in a block, the block is successfully mined and the block is broadcasted to the network, the transaction is considered as executed. Therefore also the transaction's event are only emitted at that point.

The moment you "hear" the emitted event also depends on the node you are connecting to. Some nodes get information about a block faster than others, due to network latency.

3
  • So that means events can be listened once transaction gets mined. Right?
    – NinjaMAN
    Jun 2 at 8:39
  • That means your event listener will only pick up the event once the transation gets mined Jun 2 at 8:41
  • Exactly what I mean.Thanks.
    – NinjaMAN
    Jun 2 at 8:42

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.