How rnddave/solana-staking-dashboard works
Project type and purpose
• This is a single-page web application (SPA) built with React.
• Its purpose is to let end users enter a Solana wallet address, view SOL balances, stake/unstake SOL, and track staking rewards.
• It interacts directly with an external Solana RPC endpoint (no custom backend).
File structure
Top-level:
• dashboard/public – static assets & HTML shell served to the browser
• dashboard/src – all React application code
– components/
• StakingOverview.js
• StakeUnstake.js
• RewardsTracker.js
– services/
• solana.js (encapsulates blockchain RPC calls)
– App.js (root React component & routing)
– index.js (app bootstrap)
• package.json & package-lock.json – npm dependencies & scripts
• README.md – describes architecture & usage
README for additional insights
• Uses @solana/web3.js to call RPC endpoint at https://api.mainnet-beta.solana.com
• Each UI component calls solana.js service functions (getBalance, getStakeAccounts, etc.)
• Components are currently stubs for stake/unstake & rewards, but will follow the same pattern.
a. Frontend Layer (blue)
• index.html & index.js: loads the React app into the browser.
• App.js: orchestrates rendering of child components.
• UI Components:
– StakingOverview
– StakeUnstake
– RewardsTracker
b. Service Layer (green)
• solana.js:
– Connection to Solana RPC endpoint
– Functions: getBalance(), getStakeAccounts(), (future stake/unstake calls), getRewards()
c. External Services (red)
• Solana RPC Node (https://api.mainnet-beta.solana.com)
• Underlying Solana Blockchain Network
d. Build & Deployment
• Webpack/Babel (via react-scripts)
• Static host (e.g., Netlify, Vercel, GitHub Pages)
Relationships & data flow
1. User opens browser → loads index.html → index.js
2. index.js renders App.js
3. App.js passes walletAddress down to components
4. Component (e.g., StakingOverview) calls getBalance(walletAddress) in solana.js
5. solana.js uses @solana/web3.js to send JSON-RPC to the Solana RPC endpoint
6. RPC endpoint queries the blockchain and returns data
7. solana.js resolves promise → returns SOL balance to component
8. Component updates UI
Architectural patterns & design principles
• Separation of concerns: UI components hold only presentation & input logic; all blockchain calls live in a dedicated service module.
• Single-page application with client-side routing (if extended).
• Stateless components where possible; use React hooks for data fetching and state.
• External dependency inversion: services abstract away direct RPC calls.