Streams API latency

Using Streams API and webhook.
Everything is working smoothly except timing.

For example -
webhook is called at
127.0.0.1 - - [10/Nov/2023 13:46:27] “POST /webhook HTTP/1.1” 200

but if we will have a look at the same transaction at Etherscan -
Transaction Hash:
0x9203bc230bad00fbb0ba802dc6d455680febcac267ddb986dde97ae7989b9a79
Status:
Success
Block:
10018581
19 Block Confirmations
Timestamp:
5 mins ago (Nov-10-2023 10:43:36 AM +UTC)

Etherscan is 3 min ahead of Streams

And I doubt it is network latency issue, because websocket app sample monitoring same address produce result immediately at the same host where webhook web server is running.

Hi @antonv

For each transaction trigger you will receive 2 webhooks. One webhook will be sent soon after the transaction is registered on blockchain. 2nd webhook is sent after a certain block confirmations. So the 2nd webhook is always received with a delay. Please have a look at the below docs for more details

Let me know if you have any questions

Thank you for the answer. I’m relatively new in apps developments Moralis API .

Definitely my webhook is receiving two POSTs - first one with ‘confirmed’: False
at 10:43:40 and second one at 10:46:27 with ‘confirmed’: True.
I decided that first message was with transaction in Pending state and second one with Confirmed ( Mined) state.
But from the document above :
The first webhook will come as soon as the block is mined and have confirmed:false
So fist one is mined.
Got it.

1 Like

BTW - do you have any ideas how to get decoded events from transaction in webhook?
I mean ‘swap’ event from ‘execute’ transaction function for example

You can decode using the below function. Pass the entire webhook data to the below function. It will decode all the logs from the webhook.

const decodedLogs = Moralis.Streams.parsedLogs(webhookData);