Learn getBlockTime use cases, code examples, request parameters, response structure, and tips.
The getBlockTime RPC method provides the estimated production time of a specified block, identified by its slot number. The time is returned as a Unix timestamp (seconds since the Unix epoch).This method is useful when you need to correlate block production with real-world time.
Avoid Batching for Better PerformanceBatching archival methods significantly increases latency. Batches over 10 requests are not allowed.
Timestamping Events: Determine when a particular block was produced to timestamp on-chain events.
Analyzing Block Production Intervals: Calculate the time difference between blocks (though for more detailed analysis, other methods might be combined).
Correlating Off-Chain Data: Align off-chain events or data with on-chain activity by matching block production times.
The result field of the JSON-RPC response will be either:
timestamp (i64): The estimated production time as a Unix timestamp (seconds since the Unix epoch).
null: If the timestamp is not available for the specified block (e.g., the block is very old and the data has been pruned, or the block was skipped and has no associated timestamp).
This example fetches the estimated production time for a specific slot. Remember to replace SLOT_NUMBER_TO_QUERY with an actual, recent, and confirmed slot on the network you are targeting (e.g., Mainnet Beta or Devnet).
Report incorrect code
Copy
Ask AI
# Replace SLOT_NUMBER_TO_QUERY with a valid slot, e.g., a recent one from an explorercurl https://mainnet.helius-rpc.com/?api-key=<api-key> -X POST -H "Content-Type: application/json" -d \ '{ "jsonrpc": "2.0", "id": 1, "method": "getBlockTime", "params": [ SLOT_NUMBER_TO_QUERY ] }'
Timestamp Availability: Timestamps might not be available for all blocks, especially very old ones or slots that were skipped. In such cases, the method returns null.
Estimation: The time is an estimate. It’s derived from stake-weighted mean of Vote timestamps from validators. While generally accurate, it’s not a guaranteed, cryptographically secure timestamp for every single block in the same way a blockhash is.
Node Dependence: The availability and precision might slightly vary depending on the RPC node queried, especially for very recent (not yet finalized) blocks.
This guide explains how to use getBlockTime to retrieve the estimated production timestamp for any given block on the Solana network.