getBlockProduction
Learn getBlockProduction use cases, code examples, request parameters, response structure, and tips.
The getBlockProduction
RPC method provides detailed insights into block production statistics within a specific slot range or the current epoch. It is particularly useful for monitoring validator performance, analyzing network participation, and detecting missed leader slots.
Common Use Cases
Monitor Validator Performance Track how many leader slots were assigned and how many blocks a validator actually produced.
Analyze Epoch-Wide Participation View block production data across all validators within the current or a historical epoch.
Detect Missed Slots Identify whether a validator missed their assigned slots, helping measure uptime or reliability.
Assess Network Health Evaluate overall block production efficiency as part of broader network monitoring.
Request Parameters
You can call getBlockProduction
with an optional configuration object:
commitment
(string, optional): Determines the commitment level to use. Defaults to the node’s configured level.range
(object, optional): Specifies the slot range to examine.firstSlot
(u64, required if noidentity
): Start slot (inclusive).lastSlot
(u64, optional): End slot (inclusive). If omitted, data will be returned up to the current slot.
identity
(string, optional): The base58-encoded public key of a validator. If specified, returns data only for that validator. ⚠️ Eitheridentity
orrange.firstSlot
must be provided.
Response Structure
context
(object):slot
: The slot at which the query was evaluated.
value
(object):byIdentity
: An object mapping each validator’s identity (public key) to:leaderSlots
: Number of slots assigned.blocksProduced
: Number of blocks successfully produced.
range
:firstSlot
: Start of the queried range.lastSlot
: End of the queried range.
Examples
1. Get Block Production for Current Epoch (All Validators)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockProduction"
}
Get Block Production for a Specific Validator (Current Epoch)
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockProduction",
"params": [
{
"identity": "YourValidatorPublicKeyHere"
}
]
}
Get Block Production for a Validator in a Slot Range
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockProduction",
"params": [
{
"identity": "YourValidatorPublicKeyHere",
"range": {
"firstSlot": 355104000,
"lastSlot": 355104010
}
}
]
}
Code Examples
const fetch = require('node-fetch');
async function getBlockProduction(rpcUrl) {
try {
const response = await fetch(rpcUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'getBlockProduction',
"params": [
{
"identity": "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr",
"range": {
"firstSlot": 355104000, // e.g., 355104000
"lastSlot": 355104010 // e.g., 355104010
}
}
]
}),
});
const data = await response.json();
// Print the exact full response
console.log('Full RPC Response:');
console.log(JSON.stringify(data, null, 2));
return data;
} catch (error) {
console.error('Error getting health:', error.message);
return null;
}
}
// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';
getBlockProduction(RPC_URL);
Example Response
{
"jsonrpc": "2.0",
"result": {
"context": {
"apiVersion": "2.2.16",
"slot": 355197308
},
"value": {
"byIdentity": {},
"range": {
"firstSlot": 355104000,
"lastSlot": 355104010
}
}
},
"id": 1
}
This guide should give you a solid understanding of how to use the getBlockProduction
RPC method to monitor and analyze validator and network block production on Solana.
Developer Tips
Epoch Boundaries Matter If querying by
identity
only, results are scoped to the current epoch up to the latest processed slot. For past epochs, userange.firstSlot
andrange.lastSlot
.Data Retention Depends on RPC Node Older slot ranges may not be available on all providers. CoinVera’s node infrastructure may retain more recent data.
Essential for Validator Monitoring This RPC is ideal for building dashboards that display block production stats, uptime, and slot efficiency metrics.
Enhance with
getLeaderSchedule
Pair withgetLeaderSchedule
to get a detailed view of when each validator was expected to produce blocks.Large Data Sets Warning If querying without specifying an
identity
, and over a wide slot range, expect large responses. Limit the range or filter by identity for efficient processing.
Last updated