Zero-Commission Validator: Stake with the Helius validator and keep 100% of your staking rewards with our 0% commission rate.

Quick Overview

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

Installation & Setup

npm install helius-sdk @solana/web3.js bs58
import { Helius } from 'helius-sdk';
import { Keypair, Transaction } from '@solana/web3.js';
import bs58 from 'bs58';

// Initialize Helius client
const helius = new Helius('YOUR_API_KEY');

// Your wallet keypair (load from your secure storage)
const payer = Keypair.fromSecretKey(/* your secret key */);

Staking Basics

Getting Started

Stake SOL in just 3 lines of code:

// 1. Create the staking transaction
const { serializedTx, stakeAccountPubkey } = 
  await helius.rpc.createStakeTransaction(payer.publicKey, 1.5);

// 2. Sign and send
const tx = Transaction.from(bs58.decode(serializedTx));
tx.partialSign(payer);
const signature = await helius.connection.sendRawTransaction(tx.serialize());

console.log(`Staked! Transaction: ${signature}`);
console.log(`Stake Account: ${stakeAccountPubkey}`);

The SDK automatically handles rent calculation and stake account creation. The 1.5 parameter is the amount in SOL you want to stake.

SDK Methods Reference

Complete Staking Workflow

1

Create and Delegate

// Stake 2 SOL to Helius validator
const { serializedTx, stakeAccountPubkey } = 
  await helius.rpc.createStakeTransaction(payer.publicKey, 2.0);

const tx = Transaction.from(bs58.decode(serializedTx));
tx.partialSign(payer);

const signature = await helius.connection.sendRawTransaction(tx.serialize());
console.log(`Stake created: ${stakeAccountPubkey}`);
2

Monitor Your Stakes

// Get all your Helius stake accounts
const 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)

// Begin the unstaking process
const 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.');
4

Withdraw SOL

// Check withdrawable amount
const withdrawable = await helius.rpc.getWithdrawableAmount(
  stakeAccountPubkey, 
  true  // include rent
);

if (withdrawable > 0) {
  // Create withdrawal instruction
  const withdrawInstruction = helius.rpc.getWithdrawInstruction(
    payer.publicKey,
    stakeAccountPubkey,
    payer.publicKey,  // withdraw to same wallet
    withdrawable
  );
  
  // Send using Smart Transactions for better reliability
  const signature = await helius.rpc.sendSmartTransaction(
    [withdrawInstruction], 
    [payer]
  );
  
  console.log(`Withdrawn ${withdrawable / LAMPORTS_PER_SOL} SOL`);
}

Advanced Patterns

For browser applications using wallet adapters:

// Get instructions instead of full transaction
const { instructions, stakeAccount } = await helius.rpc.getStakeInstructions(
  wallet.publicKey,
  stakeAmount
);

// Let the wallet handle transaction building and signing
const transaction = new Transaction().add(...instructions);

// Sign with wallet adapter
const signature = await wallet.sendTransaction(transaction, connection);

console.log(`Stake account: ${stakeAccount.publicKey.toBase58()}`);

Important Notes

Epoch Timing: Solana epochs last ~2 days. Stakes activate at the next epoch start, and deactivation takes effect at the current epoch end.

Rent Considerations: Stake accounts need rent-exempt reserves (~0.00228 SOL). Withdrawing the full balance closes the account.

Hardware Wallets: Users will see two signature prompts - one for the stake account (pre-signed) and one for the fee payer. Design your UX accordingly.

Quick Reference

Need a quick reminder? Here are the essential methods:

// Stake SOL
await helius.rpc.createStakeTransaction(owner, amountInSol);

// Check your stakes  
await helius.rpc.getHeliusStakeAccounts(ownerAddress);

// Start unstaking
await helius.rpc.createUnstakeTransaction(owner, stakeAccount);

// Check withdrawable amount
await helius.rpc.getWithdrawableAmount(stakeAccount, includeRent);

// Withdraw SOL
helius.rpc.getWithdrawInstruction(owner, stakeAccount, destination, amount);

Next Steps