The Helius SDK provides simple methods to handle the complete SOL staking lifecycle programmatically. Perfect for building staking interfaces, DeFi protocols, or automated staking strategies.
Create & Delegate
Set up new stake accounts and delegate to validators in one transaction
Monitor & Manage
Track rewards, check status, and manage existing stake accounts
Withdraw & Redeem
Deactivate stakes and withdraw SOL after cooldown periods
import { Helius } from 'helius-sdk';import { Keypair, Transaction } from '@solana/web3.js';import bs58 from 'bs58';// Initialize Helius clientconst helius = new Helius('YOUR_API_KEY');// Your wallet keypair (load from your secure storage)const payer = Keypair.fromSecretKey(/* your secret key */);
Stake Account: A special account that locks SOL and delegates it to a validator. Each stake account points to exactly one validator.Rewards: Validators earn rewards for securing the network. These rewards are distributed to all stake accounts delegated to that validator.Lifecycle: Create → Delegate → Earn Rewards → Deactivate → Withdraw
Why Choose Helius Validator
0% Commission: Keep 100% of your staking rewards
High Performance: Reliable block production and minimal downtime
Easy Integration: Optimized for the Helius SDK with built-in helpers
Timing & Epochs
Activation: Stakes become active at the start of the next epoch (~2 days)
Deactivation: Takes effect at the end of the current epoch
Cooldown: Deactivated stakes can be withdrawn immediately after epoch end
// Get all your Helius stake accountsconst accounts = await helius.rpc.getHeliusStakeAccounts( payer.publicKey.toBase58());console.log(`You have ${accounts.length} active stake accounts`);accounts.forEach((account, index) => { const info = account.account.data.parsed.info; const delegation = info.stake.delegation; console.log(`Stake ${index + 1}:`); console.log(` Amount: ${delegation.stake / LAMPORTS_PER_SOL} SOL`); console.log(` Activated: Epoch ${delegation.activationEpoch}`); console.log(` Status: ${info.meta.lockup.unixTimestamp === 0 ? 'Active' : 'Locked'}`);});
3
Deactivate (Start Unstaking)
Report incorrect code
Copy
Ask AI
// Begin the unstaking processconst unstakeTx = await helius.rpc.createUnstakeTransaction( payer.publicKey, stakeAccountPubkey);const tx = Transaction.from(bs58.decode(unstakeTx));tx.partialSign(payer);await helius.connection.sendRawTransaction(tx.serialize());console.log('Deactivation started. Will be withdrawable next epoch.');
// Get instructions instead of full transactionconst { instructions, stakeAccount } = await helius.rpc.getStakeInstructions( wallet.publicKey, stakeAmount);// Let the wallet handle transaction building and signingconst transaction = new Transaction().add(...instructions);// Sign with wallet adapterconst signature = await wallet.sendTransaction(transaction, connection);console.log(`Stake account: ${stakeAccount.publicKey.toBase58()}`);