Documentation Index
Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
Use this file to discover all available pages before exploring further.
Parameters
This method does not take any parameters.
Response
The slot of the lowest confirmed block available
Code Examples
Basic Request
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getFirstAvailableBlock"
}'
Using web3.js
import { Connection } from '@solana/web3.js';
const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
// Get first available block
const firstBlock = await connection.getFirstAvailableBlock();
console.log('First available block:', firstBlock);
// Get block range
async function getAvailableBlockRange() {
const firstBlock = await connection.getFirstAvailableBlock();
const currentSlot = await connection.getSlot();
return {
firstBlock,
currentSlot,
totalBlocks: currentSlot - firstBlock + 1
};
}
Notes
- Returns the slot of the lowest confirmed block available
- This is useful for determining the node’s available history
- The value may change as the node prunes old blocks
- Different nodes may return different values
- The response is immediate as it reads from the current state
Best Practices
- Use this method to determine available block range
- Consider node pruning when querying historical blocks
- Cache results when appropriate to reduce RPC load
- Handle cases where requested blocks are not available
- Use in conjunction with other block methods
Common Errors
| Code | Message | Solution |
|---|
| -32601 | Method not found | Verify you’re connected to a Solana RPC node |
| -32007 | Block information unavailable | Node may be bootstrapping or syncing |
Use Cases
-
Block Range Verification
async function verifyBlockRange(startSlot: number, endSlot: number) {
const firstBlock = await connection.getFirstAvailableBlock();
const currentSlot = await connection.getSlot();
if (startSlot < firstBlock) {
throw new Error(`Start slot ${startSlot} is before first available block ${firstBlock}`);
}
if (endSlot > currentSlot) {
throw new Error(`End slot ${endSlot} is after current slot ${currentSlot}`);
}
return {
startSlot,
endSlot,
available: true
};
}
-
Historical Data Availability
interface BlockAvailability {
firstAvailable: number;
currentSlot: number;
availableRange: number;
requestedSlot: number;
isAvailable: boolean;
}
async function checkBlockAvailability(slot: number): Promise<BlockAvailability> {
const firstBlock = await connection.getFirstAvailableBlock();
const currentSlot = await connection.getSlot();
return {
firstAvailable: firstBlock,
currentSlot,
availableRange: currentSlot - firstBlock + 1,
requestedSlot: slot,
isAvailable: slot >= firstBlock && slot <= currentSlot
};
}
-
Block History Analysis
async function analyzeBlockHistory() {
const firstBlock = await connection.getFirstAvailableBlock();
const currentSlot = await connection.getSlot();
const blocks = await connection.getBlocks(firstBlock, currentSlot);
const metrics = {
firstBlock,
currentSlot,
totalSlots: currentSlot - firstBlock + 1,
availableBlocks: blocks.length,
missingBlocks: (currentSlot - firstBlock + 1) - blocks.length,
availabilityPercentage: (blocks.length / (currentSlot - firstBlock + 1)) * 100
};
return metrics;
}