> ## 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.

# getStakeActivation

> Returns the stake activation information for a given account

## Parameters

<ResponseField name="pubkey" type="string" required>
  Public key of the stake account (base-58 encoded)
</ResponseField>

<ResponseField name="config" type="object" optional>
  Configuration object containing:

  <ResponseField name="commitment" type="string" optional>
    Commitment level (processed, confirmed, finalized)
  </ResponseField>

  <ResponseField name="epoch" type="number" optional>
    Epoch for which to calculate stake activation
  </ResponseField>
</ResponseField>

## Response

<ResponseField name="result" type="object">
  Object containing:

  <ResponseField name="state" type="string">
    Activation state (active, inactive, activating, deactivating)
  </ResponseField>

  <ResponseField name="active" type="number">
    Active stake amount in lamports
  </ResponseField>

  <ResponseField name="inactive" type="number">
    Inactive stake amount in lamports
  </ResponseField>
</ResponseField>

## Code Examples

### Basic Request

```bash theme={null}
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": "getStakeActivation",
  "params": [
    "4vJ9JU1bJJE96FWSJKvHsmmFADCg4gpZQff4P3bkLZj"
  ]
}'
```

### Using web3.js

```typescript theme={null}
import { Connection, PublicKey } from '@solana/web3.js';

const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');

// 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

| 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

1. **Stake Activation Analysis**
   ```typescript theme={null}
   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**
   ```typescript theme={null}
   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**
   ```typescript theme={null}
   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
         }
       };
     }
   }
   ```
