Base
¿Listo para usar esto en producción?
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Base
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
Many Base contracts lean on block.timestamp — vesting unlocks, staking rewards, auction deadlines, time-locked withdrawals — and off-chain services use block timestamps to order events and reconstruct history. But a timestamp on Base is a value the sequencer assigns, not a reading from a trusted clock, so treating it as precise wall-clock time leads to subtle bugs and, occasionally, exploitable contracts. This guide is for smart contract and backend developers building on Base: it covers how timestamps are set on this OP Stack rollup, what accuracy you can and cannot count on at roughly 2-second blocks, how much a sequencer can nudge them, and the patterns that keep time-based logic safe.
block.timestamp or the getBlockTimestamp helper.block.timestamp against an off-chain Date.now() or against timestamps from another chain.block.timestamp as approximate. Never compare it for equality (== someTime) or build logic that breaks if it is off by a few seconds; use inequalities with margin instead. Crucially, never derive randomness or high-value secrets from the timestamp — it is partly under the sequencer's control.