How do you prevent block.timestamp manipulation in Solidity smart contracts for time-sensitive auctions?
Moderator Note:
This thread is one of the best examples of how technical screening has changed post-Merge. We see a lot of developers searching the Solidity docs for "miner manipulation," but in today's Proof-of-Stake Ethereum, the threat model is different.
12-second slots constrain validators, which limits manipulation to a few seconds of delay rather than massive future jumps. If you are applying for a senior smart contract role, hiring managers expect you to know the difference between PoW miner manipulation and PoS validator constraints, and why block.number is safer for long-duration timelocks. Let's dive into the community discussion below.
I was asked an interview question about block.timestamp manipulation in Solidity auction contracts, and I realised my first answer was too simple.
My first thought was: “Don’t use block.timestamp; use block.number instead.” But that also does not feel fully correct, because block numbers are not a real-world clock either.
The part I understand is this: auction contracts often need start times, end times, and bidding windows. But on-chain time is approximate. A validator cannot set any timestamp they want, but a smart contract should still not assume that the last few seconds are a perfectly fair boundary.
So what is the better engineering answer here?
For time-sensitive Solidity auction contracts, do experienced engineers usually keep block.timestamp only for rough deadline checks and then add anti-sniping logic or a grace-period extension near the end?
Does commit–reveal mainly help with bid privacy and front-running rather than timestamp manipulation itself?
And when people mention OpenZeppelin TimelockController, is that actually relevant to auction design, or is it more of a governance-delay pattern?
I am looking for a clean way to explain this in Solidity interviews and production reviews without giving an outdated answer like “just use block.number.”