How to Stake With Helius Programmatically
Learn how to stake SOL on Solana using the Helius Node.js SDK with clean, programmatic flows
Welcome, Solana builder 👋 You are about to give your users a single-click staking flow while keeping full programmatic control in your codebase. The Helius Node.js SDK already wraps every low-level detail, so your job is mostly to decide when to call each helper and who signs the resulting transaction
This guide starts with general information about staking on Solana, then shows how to install the SDK, and finally walks through the full staking lifecycle with practical examples
1. Staking on Solana
Stake account A special account that locks up SOL. The SOL inside is delegated to a validator of your choice. You can have as many stake accounts as you like and each one points at exactly one validator
Rewards The validator earns rewards for producing blocks. Those rewards flow back into every stake account that selected that validator. When you use the Helius validator the commission rate is 0 %, so users keep everything
Life-cycle 1 ) Create and delegate 2 ) Cool down (optional deactivation) 3 ) Withdraw or re-delegate The helper methods map to these exact lifecycle phases
2. One-time Setup
From this point on, every snippet will assume you imported this helius
instance and that you hold a funded Keypair
called payer
.
3. Method Reference with Example Calls
createStakeTransaction
Builds a serialized, unsigned transaction that creates a new stake account, and delegates it to the Helius validator
{ serializedTx, stakeAccountPubkey }
await helius.rpc.createStakeTransaction(owner, 1.5)
getStakeInstructions
{ instructions, stakeAccount }
await helius.rpc.getStakeInstructions(owner, 1.5)
createUnstakeTransaction
Builds a serialized, unsigned transaction that sends a Deactivate
instruction to an existing stake account
serializedTx
await helius.rpc.createUnstakeTransaction(owner, stakeAcc)
getUnstakeInstruction
Single Deactivate
instruction with no wrapper transaction
TransactionInstruction
helius.rpc.getUnstakeInstruction(owner, stakeAcc)
getWithdrawableAmount
Returns the number of lamports that can be withdrawn right now from a given stake account. Pass true
to include the rent-exempt minimum into the withdrawable amount
number
await helius.rpc.getWithdrawableAmount(stakeAcc, true)
createWithdrawTransaction
Builds a serialized, unsigned transaction that moves lamports out of a stake account into any destination address. Works only after the cooldown period has ended
serializedTx
await helius.rpc.createWithdrawTransaction(owner, stakeAcc, dest, amount)
getWithdrawInstruction
Stand-alone withdraw instruction
TransactionInstruction
helius.rpc.getWithdrawInstruction(owner, stakeAcc, dest, amount)
getHeliusStakeAccounts
Returns all stake accounts that are currently delegated to the Helius validator for a given wallet
ParsedAccountData[]
await helius.rpc.getHeliusStakeAccounts(wallet)
4. Quickstart: Stake in Three Simple Steps
5. Full Lifecycle Cookbook
5.1 Fetch every stake account that delegates to Helius for a given wallet
5.2 Deactivate (begin cooldown)
5.3 Check how many lamports can be withdrawn
5.4 Withdraw part, or all, of the balance
6. Power User Patterns
Browser-only Staking Call
getStakeInstructions
, feed the returned instructions into the wallet adapter, and let the wallet build and sign the transactionBatching Loop over wallets, call
createStakeTransaction
for each, and send the blobs in parallel. Respect your rate limitSmart Transactions
7. Common Pitfalls
Epoch timing A Solana epoch lasts roughly two days. If you deactivate halfway through epoch 600, the stake stays locked until epoch 601 begins
Rent exempt minimum The stake account will be closed if you withdraw the full balance, including rent. If you withdraw less than the rent-exempt threshold, the account will remain open
Hardware wallets Users see two prompts: one signature for the new stake account (already signed within the blob) and one for the fee payer. Make sure your UX explains this
8. One-page Cheat Sheet
Next Steps
Happy building and happy earning!
Last updated
Was this helpful?