A comprehensive token staking application built on Solana devnet with Phantom wallet integration.
- Phantom Wallet Integration: Seamless connection with Phantom wallet
- SOL Airdrop: Get free SOL for testing on devnet
- Token Purchase: Buy STAKE tokens for staking
- Stake Tokens: Stake your tokens and earn rewards
- Unstake Anytime: Flexible unstaking with no lock period
- Real-time Rewards: Track and claim your staking rewards
- Modern UI: Beautiful, responsive interface built with Tailwind CSS
- Next.js 14: React framework with TypeScript
- Solana Wallet Adapter: For wallet connections
- Tailwind CSS: Utility-first CSS framework
- @solana/web3.js: Solana JavaScript SDK
- Rust: Solana program written in Rust
- Borsh: Binary serialization for account data
- Solana Program Library: Standard Solana program utilities
Before running this application, make sure you have:
- Node.js (v16 or higher)
- npm or yarn
- Phantom Wallet browser extension
- Rust (for building Solana programs)
- Solana CLI (for program deployment)
git clone <your-repo-url>
cd solana-staking-appnpm install# On macOS/Linux
sh -c "$(curl -sSfL https://release.solana.com/v1.16.0/install)"
# On Windows
curl https://release.solana.com/v1.16.0/solana-install-init-x86_64-pc-windows-msvc.exe --output C:\solana-install-tmp\solana-install-init.exe --create-dirssolana config set --url https://api.devnet.solana.com
solana-keygen newcd program
cargo build-bpfnpm run devOpen http://localhost:3000 in your browser.
npm run build
npm start- Install Phantom wallet extension
- Click "Select Wallet" and choose Phantom
- Approve the connection
- Click "Request 1 SOL Airdrop" to get free SOL
- Wait for transaction confirmation
- Enter the amount of tokens to purchase
- Click "Buy STAKE Tokens"
- Confirm the transaction in your wallet
- Enter the amount to stake
- Use percentage buttons for quick selection
- Click "Stake Tokens" and confirm
- Enter unstake amount or use "MAX"
- Click "Unstake Tokens" to withdraw and claim rewards
- Or use "Claim Rewards" to claim without unstaking
Create a .env.local file:
NEXT_PUBLIC_SOLANA_NETWORK=devnet
NEXT_PUBLIC_RPC_ENDPOINT=https://api.devnet.solana.comThe app is configured for Solana devnet by default. To change networks:
- Update
contexts/WalletProvider.tsx - Change
WalletAdapterNetwork.Devnetto desired network - Update RPC endpoint accordingly
// Instructions
- InitializePool: Create a new staking pool
- Stake: Stake tokens in the pool
- Unstake: Withdraw staked tokens
- ClaimRewards: Claim accumulated rewards
// Account Types
- StakingPool: Global pool state
- StakeAccount: Individual user stake dataTo deploy your own program:
cd program
cargo build-bpf
solana program deploy target/deploy/solana_staking_program.so- This is a demo application for educational purposes
- Smart contract includes basic security checks
- Always audit smart contracts before mainnet deployment
- Test thoroughly on devnet before production use
npm test- Wallet connection works
- Airdrop functionality
- Token purchase simulation
- Staking tokens
- Unstaking tokens
- Claiming rewards
- UI responsiveness
solana-staking-app/
βββ components/ # React components
β βββ AirdropButton.tsx
β βββ StakingInterface.tsx
β βββ TokenPurchase.tsx
βββ contexts/ # React contexts
β βββ WalletProvider.tsx
βββ pages/ # Next.js pages
β βββ _app.tsx
β βββ index.tsx
βββ program/ # Solana program (Rust)
β βββ src/
β β βββ lib.rs
β βββ Cargo.toml
βββ styles/ # CSS styles
β βββ globals.css
βββ utils/ # Utility functions
βββ package.json
βββ next.config.js
βββ tailwind.config.js
βββ README.md
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues:
- Check the troubleshooting guide
- Review Solana documentation
- Check Phantom wallet connection
- Ensure you're on devnet
Wallet won't connect:
- Ensure Phantom is installed and unlocked
- Check browser permissions
- Try refreshing the page
Airdrop fails:
- Devnet airdrop has rate limits
- Try again after a few minutes
- Check Solana network status
Transactions fail:
- Ensure sufficient SOL for gas fees
- Check wallet approval
- Verify network connection
Build errors:
- Clear node_modules and reinstall
- Check Node.js version compatibility
- Verify all dependencies are installed
https://drive.google.com/file/d/1JMSzDtCnWjLDRCm6Y99qi7kKCWwdCp5f/view?usp=sharing
Built with β€οΈ for the Solana ecosystem