> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Solana: Understanding Block Time

> How Solana sets block time under Alpenglow, how getBlockTime differs from the Clock sysvar, and how slots, blocks, and timestamps relate.

**TLDR:**

* 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.
* `getBlockTime` and `blockTime` return a block's own time. The `Clock` sysvar 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.

To follow along with the RPC examples in this guide, you'll want a [Chainstack Solana RPC](https://chainstack.com/build-better-with-solana/) endpoint.

## Key concepts

* **Slots** — scheduled intervals in which a leader can produce a block. The target slot time is 200 ms ([SIMD-0525](https://github.com/solana-foundation/solana-improvement-documents/blob/main/proposals/0525-reduce-slot-times.md)). Not every slot produces a block. See [Solana: Understanding the difference between blocks and slots](https://docs.chainstack.com/docs/understanding-the-difference-between-blocks-and-slots-on-solana.md).
* **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](https://docs.chainstack.com/docs/solana-alpenglow-consensus.md), the block's leader sets it.

## How block time is set

Every block ends with a footer that carries `block_producer_time_nanos`, a nanosecond Unix timestamp from the leader's clock ([SIMD-0307](https://github.com/solana-foundation/solana-improvement-documents/blob/main/proposals/0307-add-block-footer.md)). 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.

A block whose footer time falls outside this range is rejected. After the block's transactions run, the `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:

| Value | What it holds for block S |
| - | - |
| [getBlockTime](https://docs.chainstack.com/reference/solana-getblocktime.md), `blockTime` in [getBlock](https://docs.chainstack.com/reference/solana-getblock.md) and [getTransaction](https://docs.chainstack.com/reference/gettransaction.md), Yellowstone gRPC `block_meta.block_time` | S's own footer time, in whole seconds — when the leader finished producing S |
| `Clock.unix_timestamp` read by transactions in S | The footer time of S's parent block, in whole seconds — when the parent block ended |

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:

```shell Shell theme={"system"}
curl -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"getBlockTime","params":[SLOT_NUMBER]}' \
  CHAINSTACK_SOLANA_URL
```

Replace `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:

```shell Shell theme={"system"}
curl -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"getBlock","params":[SLOT_NUMBER, {"encoding":"json","maxSupportedTransactionVersion":1}]}' \
  CHAINSTACK_SOLANA_URL
```

Replace `SLOT_NUMBER` and `CHAINSTACK_SOLANA_URL` with your Solana node endpoint.

### Get latest slot

Check the latest slot number:

```shell Shell theme={"system"}
curl -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"getSlot"}' \
  CHAINSTACK_SOLANA_URL
```

### Get latest block height

Retrieve the latest block height (actual blocks produced):

```shell Shell theme={"system"}
curl -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"getBlockHeight"}' \
  CHAINSTACK_SOLANA_URL
```

## 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](https://docs.anza.xyz/consensus/alpenglow#clock-sysvar) in the Anza documentation.
* `slot` — the current slot.

Programs rely on this timestamp for logic like auctions or expirations.

## 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](https://docs.chainstack.com/docs/understanding-the-difference-between-blocks-and-slots-on-solana.md).
* **Incorrect expiry calculations** — use block counts (150 blocks) for transaction validity, not slot counts. See [Solana: Understanding the difference between blocks and slots](https://docs.chainstack.com/docs/understanding-the-difference-between-blocks-and-slots-on-solana.md).
* **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** — [`getBlock`](https://docs.chainstack.com/reference/solana-getblock) takes a slot number but returns block-specific information, including block height. See [Solana: Understanding the difference between blocks and slots](https://docs.chainstack.com/docs/understanding-the-difference-between-blocks-and-slots-on-solana.md).

And don't forget to code your `getBlock` calls efficiently — see [Solana: optimize your getBlock performance](https://docs.chainstack.com/docs/solana-optimize-your-getblock-performance.md).

> [card] Ake
>
> ![Ake](https://mintcdn.com/chainstack/UN3rP7zhB69idvnC/images/docs/profile_images/1719912994363326464/8_Bi4fdM_400x400.jpg?fit=max\&auto=format\&n=UN3rP7zhB69idvnC\&q=85\&s=792a24ab1b4682406fa589c0ecd88e5d)
>
> &#x20;Director of Developer Experience @ Chainstack
> \
> &#x20;Talk to me all things Web3
> \
> 20 years in technology | 8+ years in Web3 full time years experience
>
> [https://github.com/akegaviar/](https://github.com/akegaviar/)
>
> [https://twitter.com/akegaviar](https://twitter.com/akegaviar)
>
> [https://www.linkedin.com/in/ake/](https://www.linkedin.com/in/ake/)
