Staking Flow

Now let's dive into the actual API endpoints you'll use to stake your SOL. What’s Staking on Solana?

Step 1: Start Staking Your SOL

You have two options depending on your starting point:

Option A: Create New Stake Account

POST /delegations/delegate

  • Creates a new stake account and delegates SOL to Stakefish
  • Returns a transaction that must be signed and broadcast by your client
  • Use this when starting fresh with unstaked SOL

Request Body:

{
  "stakeAuthorityPubkey": "YourWalletPublicKey",
  "amountToStake": "1000000000"  // Amount in lamports (1 SOL = 1,000,000,000 lamports)
}

Important Notes:

  • amountToStake must be in lamports, not SOL
  • Value must match pattern ^[1-9]\d*$ (positive integer, no decimals, no leading zeros)
  • Conversion: multiply SOL amount by 1,000,000,000

Response:

{
  "serializedTransaction": "base64_encoded_transaction",
  "stakeAccountPubkey": "NewStakeAccountAddress",
  "voteAccountPubkey": "ValidatorVoteAddress"
}

Option B: Activate Existing Stake Account

POST /delegations/activate

  • Activates an already initialized stake account
  • Delegates the staked SOL to Stakefish validator
  • Returns a transaction for client-side signing and broadcasting
  • Use this when you have an existing inactive stake account

Sign & Broadcast Transaction

Once the transaction is prepared by our API, the final step is to sign and broadcast the transaction in order to initialize your delegation.

Sign The Transaction

Rehydrate the serialized transaction from the Base64 encoded wire transaction.

Use the same account which corresponds to the fromPubkey(which defaults to the stakeAuthorityPubkey ) as provided when creating the transaction.

Send The Transaction

Broadcast the transaction to a Solana node. The operation is completely atomic which means that once the transaction succeeds your delegation process is complete.

Activation Delay

After your transaction is confirmed, your delegation remains pending until the next epoch begins (epochs last ~48 hours). Once the new epoch starts, your delegation automatically activates and begins earning rewards.

Step 2: Check Your Active Stakes

GET /delegations/stakeAuthorityPubkey

  • Query all stake accounts associated with your stake authority
  • Returns a list of delegations (stake accounts) for monitoring
  • Replace stakeAuthorityPubkey with your actual public key

Step 3: Unstaking Your SOL

When you're ready to access your SOL again, you'll need to go through a two-step process:

Step 3a: Deactivate Your Stake

POST /delegations/undelegate

  • Initiates deactivation of your stake account
  • Required before withdrawing SOL from the stake account
  • Returns a transaction for signing and broadcasting
  • Note: Deactivation takes effect at the next epoch boundary

Step 3b: Withdraw Your SOL

POST /delegations/withdraw

  • Withdraws SOL from a deactivated stake account
  • Defaults to withdrawing to the stake authority account
  • Can specify a custom destination address
  • Only works after stake account is fully deactivated

Step 4: Advanced Operations

Merging Stake Accounts

POST /delegations/merge

  • Combines multiple source stake accounts into one target account
  • Useful for consolidating your staking positions
  • Immediate execution upon transaction confirmation
  • All accounts must have the same stake authority

Splitting Stake Accounts

POST /delegations/split

  • Divides one stake account into two separate accounts
  • Useful for partial withdrawals or redistribution
  • Immediate execution upon transaction confirmation
  • Specify the amount to split off from the source account