Network
getVersion
RPC
- HTTP RPC API
- Common Error Codes
- Methods
- Account & Program
- Blocks & Slots
- Epochs & Schedule
- Network
- Transactions & Fees
- Tokens
- Staking & Voting
- Supply & Inflation
Data Streaming
- Jetstream
- Yellowstone gRPC
Trading APIs
Network
getVersion
Returns the current version of the node
Parameters
None
Response
Code Examples
Basic Request
curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getVersion"
}'
Using web3.js
import { Connection } from '@solana/web3.js';
const connection = new Connection('https://rpc.orbitflare.com');
// Get version
const version = await connection.getVersion();
console.log('Node version:', version);
// Get version with analysis
async function getVersionWithAnalysis() {
const version = await connection.getVersion();
return {
version,
analysis: {
timestamp: Date.now(),
isLatest: await checkLatestVersion(version['solana-core'])
}
};
}
async function checkLatestVersion(currentVersion: string): Promise<boolean> {
// Implementation to check if current version is latest
// This would typically involve calling an external API
return true;
}
Notes
- Returns the current version of the node
- The version includes the Solana core software version
- The response is immediate as it reads from the current state
- The version can change with node updates
- Different nodes may run different versions
Best Practices
- Cache results when appropriate to reduce RPC load
- Monitor for version changes
- Consider using websocket subscription for real-time updates
- Handle network errors and retry when appropriate
- Keep track of version compatibility
Common Errors
Code | Message | Solution |
---|---|---|
-32601 | Method not found | Verify you’re connected to a Solana RPC node |
Use Cases
-
Version Analysis
interface VersionAnalysis { version: { core: string; featureSet?: number; }; metrics: { timestamp: number; isLatest: boolean; isCompatible: boolean; }; } class VersionAnalyzer { private readonly minCompatibleVersion = '1.8.0'; async analyzeVersion(): Promise<VersionAnalysis> { const version = await connection.getVersion(); return { version: { core: version['solana-core'], featureSet: version['feature-set'] }, metrics: { timestamp: Date.now(), isLatest: await this.checkLatestVersion(version['solana-core']), isCompatible: this.checkCompatibility(version['solana-core']) } }; } private async checkLatestVersion(currentVersion: string): Promise<boolean> { // Implementation to check if current version is latest return true; } private checkCompatibility(currentVersion: string): boolean { const [currentMajor, currentMinor] = currentVersion.split('.').map(Number); const [minMajor, minMinor] = this.minCompatibleVersion.split('.').map(Number); return currentMajor > minMajor || (currentMajor === minMajor && currentMinor >= minMinor); } }
-
Version Monitoring
interface VersionChange { changes: { previousVersion: string; currentVersion: string; type: 'upgrade' | 'downgrade'; }; metadata: { timestamp: number; }; } class VersionMonitor { private previousVersion: string | null = null; async monitorVersion(): Promise<VersionChange | null> { const version = await connection.getVersion(); const currentVersion = version['solana-core']; if (this.previousVersion !== null && this.previousVersion !== currentVersion) { const type = this.compareVersions(currentVersion, this.previousVersion) > 0 ? 'upgrade' : 'downgrade'; this.previousVersion = currentVersion; return { changes: { previousVersion: this.previousVersion, currentVersion, type }, metadata: { timestamp: Date.now() } }; } this.previousVersion = currentVersion; return null; } private compareVersions(v1: string, v2: string): number { const [major1, minor1, patch1] = v1.split('.').map(Number); const [major2, minor2, patch2] = v2.split('.').map(Number); if (major1 !== major2) return major1 - major2; if (minor1 !== minor2) return minor1 - minor2; return patch1 - patch2; } }
-
Version Planning
interface VersionPlan { currentVersion: string; recommendations: Array<{ type: 'upgrade' | 'downgrade' | 'maintain'; reason: string; }>; metadata: { timestamp: number; }; } class VersionPlanner { private readonly targetVersion = '1.9.0'; private readonly minCompatibleVersion = '1.8.0'; async planVersion(): Promise<VersionPlan> { const version = await connection.getVersion(); const currentVersion = version['solana-core']; const recommendations: Array<{ type: 'upgrade' | 'downgrade' | 'maintain'; reason: string; }> = []; // Check for version compatibility if (!this.checkCompatibility(currentVersion)) { recommendations.push({ type: 'upgrade', reason: `Current version (${currentVersion}) is not compatible with minimum version (${this.minCompatibleVersion})` }); } // Check for target version if (this.compareVersions(currentVersion, this.targetVersion) < 0) { recommendations.push({ type: 'upgrade', reason: `Current version (${currentVersion}) is below target version (${this.targetVersion})` }); } return { currentVersion, recommendations, metadata: { timestamp: Date.now() } }; } private checkCompatibility(currentVersion: string): boolean { const [currentMajor, currentMinor] = currentVersion.split('.').map(Number); const [minMajor, minMinor] = this.minCompatibleVersion.split('.').map(Number); return currentMajor > minMajor || (currentMajor === minMajor && currentMinor >= minMinor); } private compareVersions(v1: string, v2: string): number { const [major1, minor1, patch1] = v1.split('.').map(Number); const [major2, minor2, patch2] = v2.split('.').map(Number); if (major1 !== major2) return major1 - major2; if (minor1 !== minor2) return minor1 - minor2; return patch1 - patch2; } }