getBlockTime — Solana RPC Method
getBlockTime returns the estimated production time of a confirmed block as a Unix timestamp (seconds since the epoch). This is derived from the validator’s clock at the time of block creation.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
slot | u64 | Yes | Slot number of the block to query. |
This method takes only the slot number — no configuration object.
Request
curl -X POST https://api.mainnet-beta.solana.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockTime",
"params": [311857920]
}'
TypeScript (@solana/kit)
import { createSolanaRpc } from "@solana/kit";
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const timestamp = await rpc.getBlockTime(311857920n).send();
if (timestamp !== null) {
console.log(`Block time: ${new Date(Number(timestamp) * 1000).toISOString()}`);
}
Response
{
"jsonrpc": "2.0",
"result": 1729000000,
"id": 1
}
| Field | Type | Description |
|---|---|---|
result | i64 or null | Estimated Unix timestamp in seconds. null if the timestamp is not available for this block. |
Common errors
- Block not available — the slot was skipped or has been pruned. Returns
null. - Timestamp not available — very old blocks may not have a stored timestamp. Returns
null.
Performance
getBlockTime is a lightweight call that reads a single stored timestamp. The response is a single number. For bulk time lookups, fetch blocks with getBlock which includes blockTime in its response, reducing the number of round trips.
FAQ
How accurate is the block timestamp? The timestamp is based on the block producer’s local clock and is an estimate. Validator clocks can drift by a few seconds. Do not rely on it for sub-second precision.
Why does getBlockTime return null? Either the slot was skipped (no block was produced) or the block is too old for the node to have the timestamp available. Archival nodes may retain timestamps longer.
How do I convert the timestamp to a date?
Multiply by 1000 (to convert seconds to milliseconds) and pass to new Date() in JavaScript: new Date(timestamp * 1000).
What is the typical time between blocks? Solana targets 400ms per slot, so consecutive blocks are approximately 400-800ms apart, depending on the skip rate. The actual gap varies with network conditions.
Can I get the block time for a future slot?
No. The timestamp is set when the block is produced. A future or skipped slot has no timestamp and returns null.
Parameters
| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
slot | u64 | Yes | Slot number of the block. | — |
Updated: