How does Moralis order Transfer events?

I’m syncing Transfer events. I created a webhook to notify my backend before such an event is added to the database in Moralis.

Let’s say 3 transfer events appear in the same transaction. How can I know which event is the most recent one? How does Moralis order the events internally?

you will use the log index for that ordering, you can register for moralis.io/streams that is specific made to send web hooks to your backend

Thank you, but how exactly do I use the log Index? Does a higher log index imply that an event is newer?

Btw. regarding streams, do you think it is ready to be used in production?

every transaction has a number of logs/events, lower log index means that the event was triggered before another event with a higher log index in the same transaction

streams API is not ready for production, it is in closed beta phase now

1 Like

That’s great, I assume I can then order events of the same token by block number and log index.

Just one more thing, I know that events with confirmed: true have a very low chance of being dropped (according to the docs), but how does Moralis handle the situation when they are really dropped? Is the dropped event simply overwritten with the new event that has the same from and to fields?

that case is rare, my expectation now is that you could end up with two different events in the database (in case that the events are totally different after reorg), if they are identical as log index and transaction hash then there will be no difference if the event is still confirmed

2 Likes

we will work on having a way to notify in case of these type of big reorgs happen with our new streams API: moralis.io/streams