robust Solana Token Staking smart contract built with Anchor
A robust Solana Token Staking smart contract built with Anchor. Users can stake SPL tokens to earn proportional rewards over time. Features admin configuration, reward deposits, claim-only & unstake options, two-step authority transfer, and pause functionality. Includes a full TypeScript CLI for easy interaction and testing.
I open-sourced solana-token-staking-smart-contract for developers in Solana / Anchor smart contract development. This post walks through what it does, how the pieces fit together, and how to run it locally.
Why I built this
- Explore solana token staking smart contract patterns in solana / anchor smart contract development
- Fork the repo as a starter template for your own project
- Contribute features, docs, or tests via pull requests
Most tutorials stop at a smart contract or a UI mockup. I wanted a complete vertical slice โ wallet flow, on-chain logic, backend state, and a responsive frontend โ so you can study or fork a production-shaped codebase.
What it does
- Initialize / configure program โ Admin sets token mint, claim period, reward multiplier, and other parameters.
- Deposit funds โ Admin deposits reward tokens into the program vault.
- Stake tokens โ Users stake SPL tokens and start earning rew
- A robust Solana Token Staking smart contract built with Anchor
- Users can stake SPL tokens to earn proportional rewards over time
- Features admin configuration, reward deposits, claim-only & unstake options, two-step authority transfer, and pause functionality
- Lets users stake tokens, unstake (withdraw principal + rewards), or claim rewards only.
- Distributes rewards proportionally by share of total staked amount over configurable time periods.
Architecture at a glance
- On-chain program โ Anchor/Rust logic for escrow, rooms, and settlement
- Application layer โ TypeScript backend/frontend tying on-chain and off-chain flows
- Feature โ Initialize / configure program โ Admin sets token mint, claim period, reward multiplier, and other parameters.
- Feature โ Deposit funds โ Admin deposits reward tokens into the program vault.
- Feature โ Stake tokens โ Users stake SPL tokens and start earning rew
User Wallet โ On-chain Program โ VRF / Settlement
โ
Backend (API + WebSockets) โ MongoDB / state
โ
Frontend UI (real-time)
Adjust the diagram to match your repo layout if components differ.
Tech stack
- Rust
- Solana
- Anchor
- TypeScript
Quick start
git clone https://github.com/DexCrancer/solana-token-staking-smart-contract.git
cd solana-token-staking-smart-contract
Setup steps:
- Install dependencies (see README โ typically npm install or yarn)
- Copy .env.example to .env and fill in RPC, wallet, and API keys
- Run local validator or point to devnet/mainnet as documented
- Start the backend and frontend; connect wallet and create a test room
See the full README for environment variables, deploy scripts, and test commands: https://github.com/DexCrancer/solana-token-staking-smart-contract
What to explore in the repo
- Program / contract entrypoints and account models
- API routes and WebSocket event handlers
- Frontend wallet adapter and game room components
- Tests, scripts, and deployment configs
Contributing
Issues and PRs are welcome. If this helped you learn something, a โญ on GitHub makes it easier for others to find.
Links
Disclaimer: Educational content only. Not financial advice. Gambling and trading involve risk; use responsibly and comply with local laws.
anchor #defi #solana #solanasmartcontract #solanastaking #splstaking
United States
NORTH AMERICA
Related News
Secret Claude Tracker Shocks Users After Anthropic's Anti-Surveillance Stance
12h ago
EV Batteries Defy Expectations, Last Hundreds of Thousands of Miles
1d ago
GBase 8a Performance Anomaly Case Study: How a Single Parameter Change Sparked a Chain Reaction
1d ago
Who Else Has Inherited a Codebase With Zero Comments and a Prayer?
1d ago
ๅฎ็พ็ๅนณๅบธ
4h ago