Explain solidity>timestamps

Working with Time

Smart contracts can access the current block timestamp using block.timestamp.

What is block.timestamp?

block.timestamp returns the timestamp of the current block, as Unix time (seconds since Jan 1, 1970).

It's set by the validator when they create the block, so use it for coarse deadlines, not randomness or exact wall-clock timing.



Casting to uint64:

block.timestamp returns a uint256, but we use uint64 for storage efficiency.

Cast it like this: uint64(block.timestamp)



Setting Deadlines:

In startGame, set the accept deadline:

acceptDeadline = uint64(block.timestamp) + ACCEPT_TIMEOUT;

In makeMove, update the last move time:

lastMoveAt = uint64(block.timestamp);



Add timestamp tracking to startGame and makeMove.

Add timestamp tracking
0%
0 of 7 requirements passed.
Requirements:
Sets acceptDeadline in startGame
Uses block.timestamp for acceptDeadline
Casts timestamp to uint64
Adds ACCEPT_TIMEOUT to deadline
Sets lastMoveAt in makeMove
lastMoveAt uses block.timestamp
lastMoveAt casts to uint64