getBlockCommitment
Returns the commitment information for a particular block identified by slot. This includes the amount of cluster stake that has voted on the block and the total active stake for the epoch. It is useful for applications that need to assess the level of consensus a block has achieved before acting on its data.
Parameters
| # | Type | Required | Description |
|---|---|---|---|
| 1 | u64 | Yes | Slot number of the block to query |
Response
Returns an object:
| Field | Type | Description |
|---|---|---|
commitment | `array | null` |
totalStake | u64 | Total active stake in lamports for the current epoch |
Code Examples
cURL
curl http://88.216.36.108:7999 -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockCommitment",
"params": [
166974442
]
}'TypeScript
const response = await fetch("http://88.216.36.108:7999", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getBlockCommitment",
params: [
166974442
]
}),
});
const { result } = await response.json();
console.log("Total stake:", result.totalStake);Python
import requests
response = requests.post("http://88.216.36.108:7999", json={
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockCommitment",
"params": [
166974442
]
})
result = response.json()["result"]
print(f"Total stake: {result['totalStake']}")Rust
use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client.post("http://88.216.36.108:7999")
.json(&json!({
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockCommitment",
"params": [
166974442_u64
]
}))
.send().await?
.text().await?;
println!("{}", res);
Ok(())
}Example Response
{
"jsonrpc": "2.0",
"result": {
"commitment": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 497717120],
"totalStake": 497717120
},
"id": 1
}