getSlot
Returns the highest slot reached at the requested commitment.
Request
Send a JSON-RPC 2.0 POST request with method: "getSlot". The params array accepts an optional configuration object.
curl · JSON-RPCjson
{ "jsonrpc": "2.0", "id": 1, "method": "getSlot", "params": [ { "commitment": "finalized" } ]}@solana/kit
kit.tsts
import { createSolanaRpc } from "@solana/kit"; const rpc_url = "https://rpc.openinfra.sh";const rpc = createSolanaRpc(rpc_url); let slot = await rpc.getSlot().send(); console.log(slot);@solana/web3.js
web3.tsts
import { Connection, type GetSlotConfig } from "@solana/web3.js"; const connection = new Connection("https://rpc.openinfra.sh", "confirmed"); let config: GetSlotConfig = { commitment: "finalized"}; let slot = await connection.getSlot(config); console.log(slot);Rust
main.rsrs
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://rpc.openinfra.sh"), CommitmentConfig::confirmed(), ); let slot = client.get_slot().await?; println!("{}", slot); Ok(())}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| config | object | No | Optional configuration object. See fields below. |
| config.commitment | string | No | Desired finality level for the query. Accepted values: processed, confirmed, finalized (default). |
| config.minContextSlot | number | No | The minimum slot at which the request may be evaluated. |
commitment values
| Value | Description |
|---|---|
| processed | Return data from the highest slot this node has processed on the fork it currently considers best. This is the newest view, but it can still change if the cluster switches forks. |
| confirmed | Return data from the highest slot that at least two-thirds of active stake has directly voted to confirm. More stable than processed, but a weaker guarantee than finalized. |
| finalized | Return data from the highest slot that the cluster recognizes as finalized. The slot has reached maximum vote lockout in validators' vote towers and is recognized by at least two-thirds of active stake. This is the strongest commitment level. |
minContextSlot example
{ "minContextSlot": 341197000 }Response
response.jsonjson
{ "jsonrpc": "2.0", "result": 1234, "id": 1}| Field | Type | Description |
|---|---|---|
| result | u64 | The highest slot the node used to answer this request, at the requested commitment level. |