getFirstAvailableBlock — Solana RPC Method
getFirstAvailableBlock returns the slot number of the oldest confirmed block that the node still has in its ledger. Blocks before this slot have been purged. This tells you the lower bound of historical data available from this RPC endpoint.
Parameters
This method takes no parameters.
Request
curl -X POST https://api.mainnet-beta.solana.com \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getFirstAvailableBlock",
"params": []
}'
TypeScript (@solana/kit)
import { createSolanaRpc } from "@solana/kit";
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const firstSlot = await rpc.getFirstAvailableBlock().send();
console.log(`First available block at slot: ${firstSlot}`);
Response
{
"jsonrpc": "2.0",
"result": 340700000,
"id": 1
}
| Field | Type | Description |
|---|---|---|
result | u64 | Slot number of the oldest confirmed block available on this node. |
Common errors
This method has no parameters and rarely fails. The only common issue is connectivity to the RPC node.
Performance
getFirstAvailableBlock returns a single number from the node’s ledger state. It is extremely lightweight. Cache the result — the first available block only increases over time as old blocks are purged.
FAQ
How far back do most RPC nodes keep blocks? Most non-archival RPC providers keep approximately 2 epochs (roughly 4 days) of block history. The exact retention depends on the provider’s configuration. Archival nodes keep the entire ledger history from genesis.
How do I know if my RPC node is archival?
Call getFirstAvailableBlock. If the result is 0 or a very low slot number, the node is archival or near-archival. If it returns a recent slot (within a few days of the current slot), it is a standard node with limited history.
Why do nodes purge old blocks? Storing the entire Solana ledger requires multiple terabytes. Standard validators purge old data to keep storage requirements manageable. Only dedicated archival nodes retain the full history.
Can I request blocks older than the first available?
No. Calling getBlock for a slot before getFirstAvailableBlock returns null. You would need an archival RPC endpoint to access older data.
Updated: