How to get the timestamp for when the transaction has been received on the blockchain?

Hi,
I have the timestamp for sending a transaction to the Algorand blockchain. I can also find the timestamp for when the transaction is minted on the blockchain using the “wait_for_confirmation” method. But I also need the timestamp for when a transaction has been received on the blockchain (before minting). Could you please let me know if I can get that data? I am asking for both private and public Algorand blockchains.
Thanks

The time when a transaction is received by the blockchain is not well defined.
The blockchain is composed of many nodes and each node may see the transaction at a different time.
Only when a transaction is added to a block do all the nodes see and agree on the transaction.

You could imagine having blockchain software that would make nodes log when they receive a transaction. But each node may have a different time.

This issue is true for any blockchain, not just Algorand.

Note however that on Algorand a block takes less than 4s to be finalized, so the difference between when a transaction is seen by the first node and when it is recorded to the blockchain is quite small (less than 8s in the worst case unless there is congestion).

Note also that Algorand, like most blockchains (except maybe private blockchain with tight centralized clock system), cannot timestamp exactly the blocks. The timestamping is best effort.

1 Like

Thank you for your response.
Would it be possible to timestamp the first node that has received the transaction? I am asking this since I want to compare the result that I have for other blockchain platforms with Algorand. And I need to know when the data is first received on the Algorand blockchain.

Best,
Sahand

You can look at your local time you sent the API request submitting the transaction.
The first node that receives the transaction is the node you send the transaction to.

How are you doing it for other blockchains?

My teammates have done it for other blockchain platforms. I assume they have considered the first node that received the transaction.
I can look at the local time when I am sending the request, but how do I know which node has received it and what is the timestamp when that first node received the transaction?

To submit a transaction, you’re connected to a node / API service. This is the first node that receives the transaction. (It’s not a node participating in consensus but it’s still a node.)
This is true for any blockchain I believe.

If your teammates can post how they did the timestamping for other blockchains, we can give a more specific answer :slight_smile:

Do you mean one of the pre-loaded accounts that the sandbox will generate after running? I am sending the data from that node to the blockchain, I am just looking for a way to get the time stamp for the first node that receives the transaction in the Algorand blockchain. My teammates also got the timestamp for the first node that received the transaction but I am not aware of the details. Do you think there is a way to do this in Algorand?

When you said “Algorand blockchain”, I thought MainNet or TestNet.

If you are using sandbox, you may be able to get detailed logs from all the nodes.
I don’t know if this would contain the information you need though.

Also, note that performance of a very small private network like sandbox would be different from performance of a real public network. This is true for Algorand, but this is most likely even more true for other blockchains. If the goal is to compare performances of multiple blockchains, you may want to consider analyzing the public networks.

One strong competitive advantage of Algorand is that performance scales extremely well: thanks to the novel ideal of sortition, performance would not degrade substantially even when you have millions of nodes. Many other consensus algorithms -the base layer of blockchains- do not have this property and performance would significantly degrade if millions of nodes join.

I understand the performance of a blockchain platform will change in case that I run my experiment in the public network. At this step, I am running my experiments on the private network and as a next step, I will do it for public networks as well.
You have mentioned using the sandbox, I may be able to get detailed logs from all the nodes. Could you please provide more details on this? How can I get access to the logs for each node?

It would be great if I could find the timestamp for the first node that is participating in consensus. Do you think this is possible?

This is definitely not possible on Algorand MainNet to my knowledge.
And I would be very surprised if it’s possible on any public blockchain MainNet.
How did you manage to get the information for other blockchains?

For a private instance of the blockchain, you may be able to look at logs, though I’m not sure it is possible. I have not checked.
You may need to increase log level by changing the configuration file and restarting.
Information about configuration can be found there:

It is possible that increasing BaseLoggerDebugLevel to 5 may help you.
However, increasing the log level may also have a significant performance impact.

Note that when using the sandbox as private network you only have one or two nodes. See the templates from sandbox/images/algod at master · algorand/sandbox · GitHub
In addition, network in sandbox is local so you should expect that both nodes receive almost immediately the transaction.

You can “enter” the sandbox node using “./sandbox enter algod”.
From there you can do changes in configuration files.
You always need to restart all nodes to do that.

For a test with more nodes, you would need to manually set up a private network.
You can look at how sandbox is doing it and work from there.

If you need more help, I recommend you ask on Discord: Algorand as it is easier to have interactive discussion on Discord.