getBlockTime

Returns the estimated production time of a block as a Unix timestamp (seconds since the Unix epoch). Block times are estimated from validator vote timestamps and may not be available for very old blocks. This method is essential for displaying human-readable timestamps in block explorers, correlating on-chain events with wall-clock time, and building time-series analytics.

Parameters

#TypeRequiredDescription
1u64YesSlot number of the block to query

Response

Returns a single value:

FieldTypeDescription
result`i64null`

Code Examples

cURL

1curl http://[IP_ADDRESS]:[PORT] -X POST -H "Content-Type: application/json" -d '{
2  "jsonrpc": "2.0",
3  "id": 1,
4  "method": "getBlockTime",
5  "params": [
6    166974442
7  ]
8}'

TypeScript

1const response = await fetch("http://[IP_ADDRESS]:[PORT]", {
2  method: "POST",
3  headers: { "Content-Type": "application/json" },
4  body: JSON.stringify({
5    jsonrpc: "2.0",
6    id: 1,
7    method: "getBlockTime",
8    params: [
9      166974442
10    ]
11  }),
12});
13const { result } = await response.json();
14console.log("Block time:", new Date(result * 1000).toISOString());

Python

1import requests
2
3response = requests.post("http://[IP_ADDRESS]:[PORT]", json={
4    "jsonrpc": "2.0",
5    "id": 1,
6    "method": "getBlockTime",
7    "params": [
8        166974442
9    ]
10})
11result = response.json()["result"]
12from datetime import datetime; print(f"Time: {datetime.fromtimestamp(result)}")

Rust

1use reqwest::Client;
2use serde_json::json;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6    let client = Client::new();
7    let res = client.post("http://[IP_ADDRESS]:[PORT]")
8        .json(&json!({
9            "jsonrpc": "2.0",
10            "id": 1,
11            "method": "getBlockTime",
12            "params": [
13                166974442_u64
14            ]
15        }))
16        .send().await?
17        .text().await?;
18    println!("{}", res);
19    Ok(())
20}

Example Response

1{
2  "jsonrpc": "2.0",
3  "result": 1681391935,
4  "id": 1
5}