12

In a function, does block.timestamp record the time the transaction was processed, or the time the block.timestamp computational step was processed?

Is block.timestamp the time the transaction is processed, or would time and time2 differ ?

function doSomething() {

uint time = block.timestamp

// ... a few 400000 gas of other things ... //

uint time2 = block.timestamp

}
11

As per the documentation you will find

timestamp of the current block in seconds since the epoch

so you have a single timestamp (when it is created) per block therefore time1=time2

read more about timestamp at Is the block.timestamp value in Solidity seconds or milliseconds?

7

In reference to your comment about transaction timestamps, the timestamps of all transactions in a block are the same.

There can be many transactions in a block, all have the same timestamp, and all are the same timestamp as the block's.

4

block.timestamp is the value what miner decides to publish there when he or she finds a block.

It is subject to some interpretation and can be skewed, though only for a while:

How would a miner cope with a huge block time?

How does Ethereum avoid inaccurate timestamps in blocks?

https://ethereum.stackexchange.com/a/428/620

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.