Withdrawal

After you have successfully undelegated your stake, you must complete the withdrawal step in order to retrieve your SOL from the deactivated stake account.

Send the following request to our API:

curl -X POST \
  'https://api.stake.fish/v1/solana/withdraw'\
  -H 'Content-Type: application/json' \
	-H 'Authorization: YOUR_PUBLIC_API_KEY' \  
  -d '{
      "stakeAuthorityPubkey": STAKE_AUTHORITY_PUBKEY,
      "stakeAccountPubkey": STAKE_ACCOUNT_PUBKEY,
      "amountToWithdraw": "100000",
      "toPubkey": RECIPIENT_PUBKEY
    }'
📘

Important

This API requires Public API Key.


Required Fields:

  • stakeAccountPubkey: The stake account to withdraw from (must already be deactivated)
  • stakeAuthorityPubkey: The public key that controls the stake account

Optional Fields:

  • fromPubkey: The public key that will sign and fund the transaction
    • Defaults to stakeAuthorityPubkey
  • amountToWithdraw: The amount of SOL (in lamports) to withdraw
    • If not provided, the entire inactive balance will be withdrawn
  • toPubkey: The destination account to receive the withdrawn SOL
    • Defaults to stakeAuthorityPubkey

Example Request Body:

{
  "stakeAuthorityPubkey": "Aby8zv8WueGgQgqvBSMdifCGr1MXEFUhYXTEhbs2ChyE",
  "stakeAccountPubkey": "5qXJrkNpVvL9xM3sBDd9413rqXuDU2PpJZZ6H5chVJR6",
  "amountToWithdraw": "100000",
  "toPubkey": "7VGU4ZwR1e1AFekqbqv2gvjeg47e1PwMPm4BfLt6rxNk"
}

Example Response:

{
  "serializedTransaction": "AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgADBeoOx6fJLnceFv4CZ68u1zUB6f9k2fwkIAsA6ZRZ3KQUR9zlUhDKVJWQw7kjNt7wNP9oGHdZy8toGmBr4pT"
}

Sign & Broadcast Transaction

Once the withdrawal transaction is prepared by our API, the final step is to sign and broadcast it.

Sign the Transaction

Rehydrate the serialized transaction from the Base64 encoded string. Use the account corresponding to the fromPubkey (defaults to stakeAuthorityPubkey) to sign the transaction.

Send the Transaction

Broadcast the signed transaction to a Solana node. Once confirmed, the specified amount of SOL will be transferred from the stake account into the toPubkey account.