Skill 3.1.4
Identify transaction-ordering, randomness and timestamp risks
Key Concepts
Pending transactions are visible to everyone before they are included. Searchers can submit their own transactions ahead of a victim's (front-running), or place transactions before and after it (sandwich attacks) to profit from price movements. The value captured by reordering, inserting or excluding transactions is maximal extractable value (MEV). Mitigations include slippage limits and deadlines on trades, commit-reveal schemes for bids and answers, and private transaction submission.
On-chain values are not random. block.timestamp, blockhash and block.prevrandao are known to, or can be influenced by, the block proposer, and any contract can compute the same value in the same transaction. Valuable random outcomes, such as lottery winners, should use a verifiable random function service such as Chainlink VRF, or a commit-reveal scheme.
Proposers set block.timestamp within protocol rules (on proof of stake it follows the 12-second slot schedule). It is suitable for coarse deadlines measured in minutes or days, but not for precise timing or as a source of randomness.