getBlockProduction

Returns recent block production information from the current or previous epoch. This is critical for monitoring validator performance, identifying leader slots, and analyzing network participation rates. Staking operators and delegation services rely on this data to assess validator reliability and uptime.

Parameters

#TypeRequiredDescription
1objectNoConfiguration object

Configuration object fields:

FieldTypeDescription
commitmentstringCommitment level: processed, confirmed, or finalized
identitystringOnly return results for this validator identity (base-58 encoded)
rangeobjectSlot range: { firstSlot: number, lastSlot?: number }. Defaults to current epoch

Response

Returns an RpcResponse object:

FieldTypeDescription
context.slotu64The slot at which the value was read
value.byIdentityobjectDictionary of validator identities mapped to [leaderSlots, blocksProduced]
value.rangeobjectBlock production slot range: { firstSlot, lastSlot }

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": "getBlockProduction",
5  "params": [
6    { "commitment": "finalized" }
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: "getBlockProduction",
8    params: [
9      { commitment: "finalized" }
10    ]
11  }),
12});
13const { result } = await response.json();
14console.log("Validators:", Object.keys(result.value.byIdentity).length);

Python

1import requests
2
3response = requests.post("http://[IP_ADDRESS]:[PORT]", json={
4    "jsonrpc": "2.0",
5    "id": 1,
6    "method": "getBlockProduction",
7    "params": [
8        {"commitment": "finalized"}
9    ]
10})
11result = response.json()["result"]
12print(f"Validators: {len(result['value']['byIdentity'])}")

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": "getBlockProduction",
12            "params": [
13                {"commitment": "finalized"}
14            ]
15        }))
16        .send().await?
17        .text().await?;
18    println!("{}", res);
19    Ok(())
20}

Example Response

1{
2  "jsonrpc": "2.0",
3  "result": {
4    "context": { "slot": 166974442 },
5    "value": {
6      "byIdentity": {
7        "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [48, 47]
8      },
9      "range": { "firstSlot": 166950000, "lastSlot": 166974442 }
10    }
11  },
12  "id": 1
13}