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.
包含以下内容的配置对象:Commitment 级别(processed、confirmed、finalized)
代码示例
基本请求
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": "getStakeMinimumDelegation",
"params": []
}'
使用 web3.js
import { Connection } from '@solana/web3.js';
const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
// Get minimum stake delegation
const minDelegation = await connection.getStakeMinimumDelegation();
console.log('Minimum stake delegation:', minDelegation);
// Get minimum stake delegation with analysis
async function getStakeMinimumDelegationWithAnalysis(
config?: { commitment?: string }
) {
const minDelegation = await connection.getStakeMinimumDelegation(config);
return {
minDelegation,
analysis: {
inSOL: minDelegation / 1e9, // Convert lamports to SOL
metadata: {
timestamp: Date.now(),
commitment: config?.commitment
}
}
};
}
注意事项
- 返回以 lamports 为单位的最低质押委托金额
- 最低委托金额由网络设置
- 响应是即时的,因为它从当前状态读取
- 最低委托金额可能随网络升级而变化
- 此值对于确定有效的质押金额非常重要
最佳实践
- 根据需求使用适当的 commitment 级别
- 在适当时缓存结果以减少 RPC 负载
- 监控最低委托金额的变化
- 考虑使用 WebSocket 订阅获取实时更新
- 适当处理网络错误并重试
常见错误
| 错误码 | 消息 | 解决方案 |
|---|
| -32601 | Method not found | 验证是否连接到 Solana RPC 节点 |
| -32602 | Invalid params | 检查配置参数 |
| -32007 | Minimum delegation information unavailable | 节点可能正在启动或同步中 |
-
质押委托分析
interface StakeDelegationAnalysis {
minDelegation: number;
metrics: {
inSOL: number;
recommendedMinimum: number;
};
metadata: {
timestamp: number;
commitment?: string;
};
}
class StakeDelegationAnalyzer {
private readonly recommendedMultiplier = 1.1; // 10% above minimum
async analyzeStakeDelegation(
config?: { commitment?: string }
): Promise<StakeDelegationAnalysis> {
const minDelegation = await connection.getStakeMinimumDelegation(config);
return {
minDelegation,
metrics: {
inSOL: minDelegation / 1e9,
recommendedMinimum: minDelegation * this.recommendedMultiplier
},
metadata: {
timestamp: Date.now(),
commitment: config?.commitment
}
};
}
}
-
质押委托监控
interface StakeDelegationChange {
previousMinDelegation: number;
currentMinDelegation: number;
change: number;
metadata: {
timestamp: number;
};
}
class StakeDelegationMonitor {
private previousMinDelegation: number | null = null;
async monitorStakeDelegation(
config?: { commitment?: string }
): Promise<StakeDelegationChange | null> {
const currentMinDelegation = await connection.getStakeMinimumDelegation(config);
if (this.previousMinDelegation === null) {
this.previousMinDelegation = currentMinDelegation;
return null;
}
if (this.previousMinDelegation !== currentMinDelegation) {
const change: StakeDelegationChange = {
previousMinDelegation: this.previousMinDelegation,
currentMinDelegation,
change: currentMinDelegation - this.previousMinDelegation,
metadata: {
timestamp: Date.now()
}
};
this.previousMinDelegation = currentMinDelegation;
return change;
}
return null;
}
}
-
质押委托规划
interface StakeDelegationPlan {
minDelegation: number;
recommendations: Array<{
amount: number;
description: string;
inSOL: number;
}>;
metadata: {
timestamp: number;
};
}
class StakeDelegationPlanner {
private readonly tiers = [
{ multiplier: 1.1, description: 'Minimum recommended' },
{ multiplier: 2, description: 'Standard' },
{ multiplier: 5, description: 'Premium' }
];
async planStakeDelegation(
config?: { commitment?: string }
): Promise<StakeDelegationPlan> {
const minDelegation = await connection.getStakeMinimumDelegation(config);
const recommendations = this.tiers.map(tier => ({
amount: minDelegation * tier.multiplier,
description: tier.description,
inSOL: (minDelegation * tier.multiplier) / 1e9
}));
return {
minDelegation,
recommendations,
metadata: {
timestamp: Date.now()
}
};
}
}