Parameters
Public key of the stake account (base-58 encoded)
Configuration object containing:Commitment level (processed, confirmed, finalized)
Epoch for which to calculate stake activation
Response
Object containing:Activation state (active, inactive, activating, deactivating)
Active stake amount in lamports
Inactive stake amount in lamports
Code Examples
Basic Request
curl https://rpc.orbitflare.com -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getStakeActivation",
"params": [
"4vJ9JU1bJJE96FWSJKvHsmmFADCg4gpZQff4P3bkLZj"
]
}'
Using web3.js
import { Connection, PublicKey } from '@solana/web3.js';
const connection = new Connection('https://rpc.orbitflare.com');
// Get stake activation
const stakeAccount = new PublicKey('4vJ9JU1bJJE96FWSJKvHsmmFADCg4gpZQff4P3bkLZj');
const activation = await connection.getStakeActivation(stakeAccount);
console.log('Stake activation:', activation);
// Get stake activation with analysis
async function getStakeActivationWithAnalysis(
stakeAccount: PublicKey,
config?: { commitment?: string; epoch?: number }
) {
const activation = await connection.getStakeActivation(stakeAccount, config);
return {
activation,
analysis: {
totalStake: activation.active + activation.inactive,
activePercentage: (activation.active / (activation.active + activation.inactive)) * 100,
state: activation.state,
metadata: {
timestamp: Date.now(),
epoch: config?.epoch,
commitment: config?.commitment
}
}
};
}
Notes
- Returns the stake activation information for a given stake account
- The activation state indicates whether the stake is active, inactive, activating, or deactivating
- The response is immediate as it reads from the current state
- The stake activation can change based on the epoch and commitment level
- The stake account must be a valid stake account
Best Practices
- Use appropriate commitment level based on your needs
- Cache results when appropriate to reduce RPC load
- Monitor for changes in stake activation
- Consider using websocket subscription for real-time updates
- Handle network errors and retry when appropriate
Common Errors
| Code | Message | Solution |
|---|
| -32601 | Method not found | Verify you’re connected to a Solana RPC node |
| -32602 | Invalid params | Check stake account public key |
| -32007 | Stake account not found | Verify the stake account exists |
| -32008 | Invalid stake account | Verify the account is a valid stake account |
Use Cases
-
Stake Activation Analysis
interface StakeActivationAnalysis {
account: string;
activation: {
state: string;
active: number;
inactive: number;
};
metrics: {
totalStake: number;
activePercentage: number;
activationProgress?: number;
deactivationProgress?: number;
};
metadata: {
timestamp: number;
epoch?: number;
commitment?: string;
};
}
class StakeActivationAnalyzer {
async analyzeStakeActivation(
stakeAccount: PublicKey,
config?: { commitment?: string; epoch?: number }
): Promise<StakeActivationAnalysis> {
const activation = await connection.getStakeActivation(stakeAccount, config);
const metrics = {
totalStake: activation.active + activation.inactive,
activePercentage: (activation.active / (activation.active + activation.inactive)) * 100
};
if (activation.state === 'activating' || activation.state === 'deactivating') {
const progress = (activation.active / (activation.active + activation.inactive)) * 100;
if (activation.state === 'activating') {
metrics.activationProgress = progress;
} else {
metrics.deactivationProgress = progress;
}
}
return {
account: stakeAccount.toBase58(),
activation,
metrics,
metadata: {
timestamp: Date.now(),
epoch: config?.epoch,
commitment: config?.commitment
}
};
}
}
-
Stake Activation Monitoring
interface StakeActivationChange {
account: string;
previousState: string;
currentState: string;
activeChange: number;
inactiveChange: number;
metadata: {
timestamp: number;
epoch?: number;
};
}
class StakeActivationMonitor {
private previousStates: Map<string, { state: string; active: number; inactive: number }> = new Map();
async monitorStakeActivation(
stakeAccount: PublicKey,
config?: { commitment?: string; epoch?: number }
): Promise<StakeActivationChange | null> {
const activation = await connection.getStakeActivation(stakeAccount, config);
const accountKey = stakeAccount.toBase58();
const previous = this.previousStates.get(accountKey);
if (!previous) {
this.previousStates.set(accountKey, {
state: activation.state,
active: activation.active,
inactive: activation.inactive
});
return null;
}
if (previous.state !== activation.state ||
previous.active !== activation.active ||
previous.inactive !== activation.inactive) {
const change: StakeActivationChange = {
account: accountKey,
previousState: previous.state,
currentState: activation.state,
activeChange: activation.active - previous.active,
inactiveChange: activation.inactive - previous.inactive,
metadata: {
timestamp: Date.now(),
epoch: config?.epoch
}
};
this.previousStates.set(accountKey, {
state: activation.state,
active: activation.active,
inactive: activation.inactive
});
return change;
}
return null;
}
}
-
Stake Activation Planning
interface StakeActivationPlan {
account: string;
currentState: string;
targetState: string;
steps: Array<{
action: string;
estimatedTime: number;
requiredStake: number;
}>;
metadata: {
timestamp: number;
currentEpoch: number;
};
}
class StakeActivationPlanner {
private readonly slotsPerEpoch = 432000; // Solana's slots per epoch
private readonly slotsPerSecond = 2; // Solana's target slot rate
async planStakeActivation(
stakeAccount: PublicKey,
targetState: string
): Promise<StakeActivationPlan> {
const [activation, currentEpoch] = await Promise.all([
connection.getStakeActivation(stakeAccount),
connection.getEpochInfo()
]);
const steps: Array<{
action: string;
estimatedTime: number;
requiredStake: number;
}> = [];
if (activation.state !== targetState) {
if (targetState === 'active' && activation.state === 'inactive') {
steps.push({
action: 'activate',
estimatedTime: (this.slotsPerEpoch / this.slotsPerSecond) / 2, // Half an epoch
requiredStake: activation.active + activation.inactive
});
} else if (targetState === 'inactive' && activation.state === 'active') {
steps.push({
action: 'deactivate',
estimatedTime: (this.slotsPerEpoch / this.slotsPerSecond) / 2, // Half an epoch
requiredStake: activation.active + activation.inactive
});
}
}
return {
account: stakeAccount.toBase58(),
currentState: activation.state,
targetState,
steps,
metadata: {
timestamp: Date.now(),
currentEpoch: currentEpoch.epoch
}
};
}
}