A minimal dApp to connect a Solana wallet and stake SOL to a validator on devnet. Built with Next.js, @solana/web3.js, and the Solana wallet adapter. Uses the free public devnet RPC (api.devnet.solana.com).
pnpm install
pnpm devOpen http://localhost:3000.
-
Switch your wallet to devnet. Phantom: Settings → Developer Settings → Testnet Mode → Devnet. Solflare: Settings → Network → Devnet.
-
Connect your wallet. Click Select Wallet in the top-right.
-
Get devnet SOL. Click Airdrop 1 SOL. (You need ~0.003 SOL for rent + fees on top of whatever you stake.)
-
Pick a validator and stake.
- Choose a validator from the dropdown (sorted by total stake).
- Enter the amount of SOL.
- Click Stake to Validator and approve the transaction.
-
Wait one epoch. Your stake account appears in Your stake accounts with status
activating. Devnet epochs are ~1–2 hours; once it flips toactive, you're earning rewards.
- Click Deactivate on the stake account. Approve the tx.
- Wait for the next epoch — status flips to
inactive. - Click Withdraw to send the SOL back to your wallet.
| State | Meaning |
|---|---|
activating |
Delegated; will activate at next epoch boundary |
active |
Earning rewards |
deactivating |
Cooling down; withdrawable at next epoch |
inactive |
Ready to withdraw |
src/
├── app/ Next.js App Router pages + layout
├── components/
│ ├── wallet-provider.tsx ConnectionProvider(devnet) + WalletProvider
│ ├── wallet-button.tsx WalletMultiButton (client-only)
│ ├── status-banner.tsx Tx status toasts
│ └── staking-dashboard.tsx All staking UI + hooks
└── lib/
├── format.ts lamports → SOL helpers
└── staking.ts Build create+delegate / deactivate / withdraw txs
- Every successful tx links to https://explorer.solana.com (devnet) so you can inspect it on chain.
- Devnet airdrops are rate-limited. If
Airdrop 1 SOLfails, wait a minute and try again, or use https://faucet.solana.com. - The dApp creates a new stake account for each stake action. You can have many.