Source
get_block_heightParameters
config
Configuration object containing the following fields:
Result
result
Block height the node used to answer this request.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
RPC methods
CLI reference
Network constants
curl https://api.devnet.solana.com -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockHeight",
"params": [
{
"commitment": "finalized"
}
]
}
'
import { createSolanaRpc } from "@solana/kit";
const rpc_url = "https://api.devnet.solana.com";
const rpc = createSolanaRpc(rpc_url);
let blockHeight = await rpc.getBlockHeight().send();
console.log("block height:", blockHeight);
import { Connection, clusterApiUrl } from "@solana/web3.js";
const connection = new Connection(clusterApiUrl("devnet"), "confirmed");
let blockHeight = await connection.getBlockHeight();
console.log("block height:", blockHeight);
use anyhow::Result;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_commitment_config::CommitmentConfig;
#[tokio::main]
async fn main() -> Result<()> {
let client = RpcClient::new_with_commitment(
String::from("https://api.devnet.solana.com"),
CommitmentConfig::confirmed(),
);
let block_height = client.get_block_height().await?;
println!("Block height: {:#?}", block_height);
Ok(())
}
{
"jsonrpc": "2.0",
"result": 1233,
"id": 1
}
Returns the block height the node sees at the requested commitment.
curl https://api.devnet.solana.com -s -X POST \
-H "Content-Type: application/json" \
-d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockHeight",
"params": [
{
"commitment": "finalized"
}
]
}
'
import { createSolanaRpc } from "@solana/kit";
const rpc_url = "https://api.devnet.solana.com";
const rpc = createSolanaRpc(rpc_url);
let blockHeight = await rpc.getBlockHeight().send();
console.log("block height:", blockHeight);
import { Connection, clusterApiUrl } from "@solana/web3.js";
const connection = new Connection(clusterApiUrl("devnet"), "confirmed");
let blockHeight = await connection.getBlockHeight();
console.log("block height:", blockHeight);
use anyhow::Result;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_commitment_config::CommitmentConfig;
#[tokio::main]
async fn main() -> Result<()> {
let client = RpcClient::new_with_commitment(
String::from("https://api.devnet.solana.com"),
CommitmentConfig::confirmed(),
);
let block_height = client.get_block_height().await?;
println!("Block height: {:#?}", block_height);
Ok(())
}
{
"jsonrpc": "2.0",
"result": 1233,
"id": 1
}
get_block_heightShow propertiesHide properties
processed, confirmed, finalizedSolana RPC uses the following commitment levels:| Value | Description |
|---|---|
processed | Return data from the highest slot this node has processed. This is the newest view, but the block can still be skipped. |
confirmed | Return data from the same slot as finalized. Kept for compatibility and planned for removal in a later release. |
finalized | Return data from the highest slot with a finalization certificate, from votes by 80% of stake in one round or 60% of stake in each of two rounds. This is the strongest commitment level. |
{ "minContextSlot": 341197000 }