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
Commitment level (processed, confirmed, finalized)
Response
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": "getSlot",
"params": []
}'
Request with Commitment
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": "getSlot",
"params": [
{
"commitment": "confirmed"
}
]
}'
Using web3.js
import { Connection } from '@solana/web3.js';
const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
// Get current slot
const slot = await connection.getSlot();
console.log('Current slot:', slot);
// Get slot with commitment
async function getSlotWithCommitment(
commitment: 'processed' | 'confirmed' | 'finalized' = 'confirmed'
) {
const slot = await connection.getSlot(commitment);
return {
slot,
commitment,
timestamp: Date.now()
};
}
Notes
- Returns the current slot of the node
- The slot number increases as new blocks are produced
- Different commitment levels can be specified
- The response is immediate as it reads from the current state
- The slot number is used for various time-based operations
Best Practices
- Cache the slot number when appropriate
- Consider using websocket subscription for real-time updates
- Handle network errors and retry when appropriate
- Use appropriate commitment level based on your needs
- Monitor slot progression for time-sensitive operations
Common Errors
| Code | Message | Solution |
|---|
| -32601 | Method not found | Verify you’re connected to a Solana RPC node |
| -32602 | Invalid params | Check config parameters |
| -32007 | Slot information unavailable | Node may be bootstrapping or syncing |
Use Cases
-
Slot Monitoring
interface SlotInfo {
slot: number;
commitment: string;
metadata: {
timestamp: number;
previousSlot: number | null;
slotProgression: number;
};
}
class SlotMonitor {
private previousSlot: number | null = null;
async monitorSlot(
commitment: 'processed' | 'confirmed' | 'finalized' = 'confirmed',
interval: number = 1000
): Promise<SlotInfo> {
const slot = await connection.getSlot(commitment);
const timestamp = Date.now();
const info: SlotInfo = {
slot,
commitment,
metadata: {
timestamp,
previousSlot: this.previousSlot,
slotProgression: this.previousSlot !== null
? slot - this.previousSlot
: 0
}
};
this.previousSlot = slot;
return info;
}
}
-
Slot Analysis
interface SlotAnalysis {
currentSlot: number;
slotProgression: {
average: number;
min: number;
max: number;
samples: number;
};
timeDistribution: {
slotsPerSecond: number;
slotsPerMinute: number;
slotsPerHour: number;
};
metadata: {
startTime: number;
duration: number;
};
}
async function analyzeSlots(
commitment: 'processed' | 'confirmed' | 'finalized' = 'confirmed',
duration: number = 60000
): Promise<SlotAnalysis> {
const startTime = Date.now();
const startSlot = await connection.getSlot(commitment);
const progressions: number[] = [];
let previousSlot = startSlot;
while (Date.now() - startTime < duration) {
const currentSlot = await connection.getSlot(commitment);
progressions.push(currentSlot - previousSlot);
previousSlot = currentSlot;
await new Promise(resolve => setTimeout(resolve, 1000));
}
const totalProgression = progressions.reduce((sum, p) => sum + p, 0);
const durationSeconds = (Date.now() - startTime) / 1000;
return {
currentSlot: previousSlot,
slotProgression: {
average: totalProgression / progressions.length,
min: Math.min(...progressions),
max: Math.max(...progressions),
samples: progressions.length
},
timeDistribution: {
slotsPerSecond: totalProgression / durationSeconds,
slotsPerMinute: (totalProgression / durationSeconds) * 60,
slotsPerHour: (totalProgression / durationSeconds) * 3600
},
metadata: {
startTime,
duration: Date.now() - startTime
}
};
}
-
Slot Synchronization
interface SlotSync {
currentSlot: number;
targetSlot: number;
difference: number;
estimatedTime: number;
metadata: {
timestamp: number;
commitment: string;
};
}
class SlotSynchronizer {
private readonly targetSlotsPerSecond = 2; // Solana's target slot rate
async checkSynchronization(
commitment: 'processed' | 'confirmed' | 'finalized' = 'confirmed'
): Promise<SlotSync> {
const currentSlot = await connection.getSlot(commitment);
const targetSlot = Math.floor(
(Date.now() / 1000) * this.targetSlotsPerSecond
);
return {
currentSlot,
targetSlot,
difference: currentSlot - targetSlot,
estimatedTime: Math.abs(currentSlot - targetSlot) / this.targetSlotsPerSecond,
metadata: {
timestamp: Date.now(),
commitment
}
};
}
}