Question about note fields in AssetTxns

Is there any way to restrict the note field in AssetTxns such that only the manager address can set it?

I am trying to set the timestamp of an AssetTxn in the note field whenever a sender makes an AssetTxn to my smart contract.

I also do not want to use the sender’s local storage to store the timestamp for reasons that are not relevant to this post.

No, who signs the transactions would always be able to append data in note field arbitrarily.

You don’t really need to do that, since TEAL can simply access the transaction’s block timestamp directly as a transaction property and perform whatever check you like on it.

1 Like

Side question: The Global.latest_timestamp() returns a uint64. How can I interpret this into an actual timestamp? Do the last 2 digits of the Global.latest_timestamp() represent seconds?

As per global opcode definition, the LatestTimestamp returns a uint64 representing the Last confirmed block UNIX timestamp.

The UNIX timestamp is the number of seconds that have elapsed since the Unix epoch. The Unix epoch is 00:00:00 UTC on 1 January 1970.

So you need a conversion.

1 Like

To add to what @cusma wrote, the LatestTimestamp is the timestamp that is taken from the previous block header ( i.e. that last block that was agreed upon ).
It’s the proposer who sets this value; this value has two limitation:

  • it must be monotonic growing.
  • it must be at most 25s greater then the preceding block header timestamp.

As long as we have constant block rate of 4.3 seconds, it always works fine. However, when the network have longer round times ( it does happen from time to time ), the value of the LatestTimestamp might be lagging behind for a while.

The reason I’m mentioning this is so that you won’t try to use this as an atomic clock - there are no guarantees about the accuracy of this clock. The Algorand blockchain itself doesn’t use this value, other than providing it as a service for the smart contracts.