Parameters

pubkey
string
required

Public key of the stake account (base-58 encoded)

config
object

Configuration object containing:

commitment
string

Commitment level (processed, confirmed, finalized)

epoch
number

Epoch for which to calculate stake activation

Response

result
object

Object containing:

state
string

Activation state (active, inactive, activating, deactivating)

active
number

Active stake amount in lamports

inactive
number

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

  1. Returns the stake activation information for a given stake account
  2. The activation state indicates whether the stake is active, inactive, activating, or deactivating
  3. The response is immediate as it reads from the current state
  4. The stake activation can change based on the epoch and commitment level
  5. The stake account must be a valid stake account

Best Practices

  1. Use appropriate commitment level based on your needs
  2. Cache results when appropriate to reduce RPC load
  3. Monitor for changes in stake activation
  4. Consider using websocket subscription for real-time updates
  5. Handle network errors and retry when appropriate

Common Errors

CodeMessageSolution
-32601Method not foundVerify you’re connected to a Solana RPC node
-32602Invalid paramsCheck stake account public key
-32007Stake account not foundVerify the stake account exists
-32008Invalid stake accountVerify the account is a valid stake account

Use Cases

  1. 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
          }
        };
      }
    }
    
  2. 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;
      }
    }
    
  3. 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
          }
        };
      }
    }