- Slots are scheduled intervals with a 200 ms target, and a block exists only if the slot’s leader produces one.
- The leader of each block writes its wall-clock time into the block footer. Validators accept that time only if it is later than the parent block’s time and no more than twice the elapsed slot duration after it.
getBlockTimeandblockTimereturn a block’s own time. TheClocksysvar that the block’s transactions read holds the parent block’s time.- Block time has whole-second resolution, so treat it as approximate and keep a margin around time-based logic.
Key concepts
- Slots — scheduled intervals in which a leader can produce a block. The target slot time is 200 ms (SIMD-0525). Not every slot produces a block. See Solana: Understanding the difference between blocks and slots.
- Blocks — actual data structures containing transactions, state changes, and related metadata. Blocks only exist if validators successfully produce them.
- Block time — the Unix timestamp attached to a block. Since Alpenglow, the block’s leader sets it.
How block time is set
Every block ends with a footer that carriesblock_producer_time_nanos, a nanosecond Unix timestamp from the leader’s clock (SIMD-0307). The leader records it when it finishes producing the block.
Validators that replay the block check the footer time against the parent block’s time:
- Lower bound — the footer time must be later than the parent block’s time.
- Upper bound — the footer time must be no later than the parent block’s time plus twice the duration of the slots between the parent and this block.
Clock sysvar is updated to the footer time, rounded down to whole seconds.
Before Alpenglow, block time was the stake-weighted median of validators’ vote timestamps. Votes are no longer on-chain transactions, so that mechanism no longer applies.
blockTime and the Clock sysvar
The time an RPC node reports for a block and the time the block’s transactions read are two different values:
To reproduce the clock a historical transaction saw — for example, when you re-simulate a deadline check — take the parent slot from
getBlock (parentSlot) and use that slot’s block time, not the block time of the transaction’s own block.
Block time has whole-second resolution and slots are shorter than a second, so consecutive blocks often share the same blockTime.
Off-chain time retrieval via JSON-RPC
Get block time
Retrieve the Unix timestamp for a given slot:SLOT_NUMBER with the desired slot and CHAINSTACK_SOLANA_URL with your Solana node endpoint.
Get detailed block information
Retrieve block details including block time, block hash, and the parent slot:SLOT_NUMBER and CHAINSTACK_SOLANA_URL with your Solana node endpoint.
Get latest slot
Check the latest slot number:Get latest block height
Retrieve the latest block height (actual blocks produced):On-chain time: Clock sysvar
Solana programs read the current time from the Clock sysvar:
unix_timestamp— a whole-second timestamp. During transaction execution, it holds the parent block’s time, so it estimates when the parent block ended rather than when the current block began. See Clock sysvar in the Anza documentation.slot— the current slot.
Best practices for time-sensitive logic
- Use on-chain time — use the on-chain timestamp (
Clock::get()?.unix_timestamp) for on-chain logic. Do not depend on client-side or local times. - Keep a margin — the timestamp has whole-second resolution and trails the current block, so leave at least a few seconds of buffer around deadlines.
- Blocks vs. slots — transaction expiration is based on blocks, not slots: a recent blockhash stays valid for 150 blocks. Skipped slots don’t count toward that window.
Common pitfalls
- Misinterpreting slots and blocks — slots represent intervals; blocks represent successful data production. The difference can span millions. See Solana: Understanding the difference between blocks and slots.
- Incorrect expiry calculations — use block counts (150 blocks) for transaction validity, not slot counts. See Solana: Understanding the difference between blocks and slots.
- Using a block’s own time as its transactions’ clock — transactions in block S read the parent block’s time. Use the parent slot’s block time when you reproduce on-chain time checks.
- RPC method confusion —
getBlocktakes a slot number but returns block-specific information, including block height. See Solana: Understanding the difference between blocks and slots.
getBlock calls efficiently — see Solana: optimize your getBlock performance.
