Moonly

Solana NFT staking platform with on-chain missions and raffles

Moonly
Next.js 14TypeScriptAnchorRustSolanaGraphQLPostgreSQLRedis

Overview

Moonly is a Solana blockchain analytics and NFT staking platform. Users stake NFTs into rule-based missions to earn token rewards, participate in on-chain raffles with NFT and SOL prizes, and browse NFT collections with real-time analytics. The platform supports multiple Solana wallet providers and serves thousands of NFT holders across dozens of collections.

Full-stack blockchain developer responsible for the entire Solana integration layer. Built three Anchor smart contracts from scratch (Mission, Raffle, Project Staking), developed the complete frontend for staking, missions, and raffles, implemented 13+ wallet adapter integrations with multi-wallet linking, created the KDOS whitelist system with automated video generation, and contributed 829 commits across the NX monorepo spanning Rust programs, TypeScript frontend, GraphQL API, and database schemas.

The platform runs as an NX monorepo with 36 applications and 9+ shared libraries. The blockchain layer alone includes three Anchor programs with comprehensive test suites, client SDK wrappers in TypeScript, GraphQL resolvers for transaction validation, and Recoil-based state management synchronizing on-chain data with the UI in real-time.

Technical Highlights

Mission Program (Anchor/Rust): Designed and built a complex NFT staking program where project owners create missions with configurable rules — AND/OR logic for collection eligibility, trait-based filtering, time-locked staking slots, and multi-token reward distribution. The program supports programmable NFTs (pNFTs) through Metaplex Token Metadata delegation and locking, boosted reward intervals with configurable multipliers, attribute-based reward bonuses, and auto-return after lock periods. Account structures use adaptive sizing to minimize rent costs while supporting up to 100 staked NFTs per user pool.

Raffle Program (Anchor/Rust): Built a decentralized lottery system supporting three ticket types — SOL payment, SPL token purchase, and mission-staking-based entry. Each raffle supports multiple prizes (NFT, SFT, SOL) with independent status tracking (vacant, unclaimed, claimed, unsold). Winner selection triggers via BullMQ job scheduler with retry logic, and unclaimed prizes are withdrawable by the admin after expiration. The program includes fee collection via a global vault and time-gated operations preventing modifications after raffle start.

Multi-Wallet Integration: Integrated 13+ Solana wallet adapters — Phantom, Solflare, Backpack, Ledger, Trust Wallet, Coin98, and more — with a multi-wallet linking system. Users connect multiple wallets to a single account through signature verification: the app generates a random challenge, the user signs it with each wallet, and the backend verifies the signature to link wallets. Supports primary wallet designation, one-click logout, and mobile wallet adapters for in-app browsers.

Real-Time Staking UI: Built the complete staking frontend with Recoil state management synchronizing on-chain data. Features include multi-NFT selection with bulk stake/unstake/claim operations, real-time reward calculation with animated counters, trait-based reward display on NFT cards, collection floor price caching via Redis, mission whitelisting with wallet-level access control, and responsive design across desktop, tablet, and mobile. Each transaction handles compute budget optimization for pNFT operations and combines multiple instructions into single transactions where possible.

Key Features

  • NFT Staking Missions: Rule-based missions with AND/OR collection eligibility, trait filtering, time-locked slots, and configurable reward tokens
  • On-Chain Raffles: SOL, SPL token, and staking-based ticket types with multi-prize management (NFT, SFT, SOL)
  • 13+ Wallet Adapters: Phantom, Solflare, Backpack, Ledger, and more with multi-wallet linking via signature verification
  • pNFT Support: Programmable NFT staking through Metaplex Token Metadata delegation, locking, and revocation
  • Boosted Rewards: Configurable multipliers that increase rewards at set time intervals, with per-trait attribute bonuses
  • Bulk Operations: Multi-select stake, unstake, and claim for multiple NFTs in batched transactions with compute budget optimization
  • Mission Admin: Rule management (AND/OR), reward configuration, whitelist management, vault deposits/withdrawals, and fee settings
  • Raffle Admin: Prize management, scheduled draws via BullMQ, retry logic for failed jobs, and unsold prize withdrawal
  • Real-Time Rewards: Animated reward counters, collection floor price caching, and block time synchronization
  • KDOS Whitelist: Automated video generation via Remotion, Twitter bot integration, and Discord verification

Challenges & Solutions

Programmable NFT Staking: Standard NFT staking uses simple token transfers, but Metaplex programmable NFTs (pNFTs) require a different approach — delegation and locking through the Token Metadata program rather than direct custody. Built the staking flow to detect NFT type at runtime, use MPL Token Metadata's Delegate and Lock instructions for pNFTs, and Unlock and Revoke on withdrawal. Each pNFT operation requires significantly more compute units, so the transaction builder dynamically sets compute budget based on NFT type and batch size.

Rule-Based Mission Architecture: Mission owners needed flexible eligibility rules — "any NFT from Collection A OR Collection B" vs "one NFT from Collection A AND one from Collection B." Designed a rule system in the Anchor program where each rule specifies a candy machine address, required count, and optional trait/value filters. The frontend renders rules as visual cards, validates NFT eligibility client-side before submitting transactions, and syncs rule state with the require card UI component in real-time.

Reward Calculation Across Time Zones: Staking rewards accrue per-second based on on-chain block time, but the frontend needs to show real-time counters that match the blockchain's clock. Built a time synchronization system that fetches the latest block time on page load, calculates the drift between client and chain clocks, and applies the offset to reward calculations. The animated counter increments locally between RPC fetches, and recalibrates on each new block time reading to prevent drift accumulation.

Multi-Transaction Batching: Users staking 10+ NFTs can't fit all instructions in a single Solana transaction (1232-byte limit). Built a transaction batching system that groups stake instructions into optimally-sized transactions, submits them sequentially, tracks success/failure per batch, and updates the UI progressively. If a batch fails mid-way, the state synchronization logic detects which NFTs were actually staked on-chain and reconciles the UI accordingly.

Adaptive Account Sizing: Solana accounts require rent proportional to their size, but mission accounts grow as rules and rewards are added. Rather than allocating maximum size upfront (expensive), implemented adaptive sizing — accounts start small and expand via realloc when new rules or rewards are added. The Mission program calculates exact byte requirements for each rule/reward combination and requests only the space needed, reducing rent costs for mission owners.

Raffle Draw Reliability: Drawing raffle winners requires an on-chain transaction, but automated draws via BullMQ can fail due to RPC congestion, network issues, or insufficient SOL. Built a resilient draw pipeline: the scheduler queues a draw job with configurable delay, the worker submits the transaction with retry logic, failed jobs are re-queued with exponential backoff, and a GraphQL resolver exposes job status so admins can manually retry from the dashboard.

Tech Stack

Next.js 14

Frontend framework with App Router

React 18

UI with server and client components

TypeScript

Type safety across frontend and backend

Anchor

Solana smart contract framework

Rust

On-chain program development

Solana Web3.js

Blockchain interaction and transaction building

Metaplex

NFT metadata, delegation, and pNFT support

GraphQL

API layer with Apollo Server and Client

PostgreSQL

Primary database (Prisma ORM)

Redis

Metadata caching and session management

BullMQ

Background job processing and raffle draws

Recoil

Frontend state management for staking data

Tailwind CSS

UI styling with responsive design

NX

Monorepo build orchestration (36 apps)

Remotion

Programmatic video generation for KDOS

PM2

Process management for 30+ services

What I Learned

  • Designing and deploying Solana smart contracts with Anchor — account sizing strategies, PDA derivation, cross-program invocations, and the constraints of the 1232-byte transaction limit
  • Working with Metaplex Token Metadata for programmable NFT operations — delegation, locking, and the differences between standard and pNFT staking flows
  • Building real-time blockchain UIs that synchronize on-chain state with frontend state management — handling block time drift, transaction confirmation, and optimistic updates
  • Multi-wallet integration across 13+ Solana wallet providers — adapter patterns, signature verification for wallet linking, and the nuances of mobile vs desktop wallet experiences
  • Contributing to a large-scale production platform as part of a team — working within an NX monorepo with 36 apps, coordinating across frontend, backend, and smart contract changes, and maintaining shared libraries used by multiple services