A decentralized social game built on Solana where players engage in strategic message-based gameplay within 24-hour time windows. The game combines blockchain technology, social interaction, and game theory to create an engaging competitive experience.
- Blockchain: Solana
- Frontend: Next.js (React)
- Styling: Tailwind CSS
- State Management: React Hooks + Custom Context
- Wallet Integration: Solana Wallet Adapter
- Backend: NextJS API Routes
- Database: MongoDB
- Authentication: JWT
- API Integration: Gary API for social interaction
-
HeroSection (
components/hero.tsx)- Wallet connection management
- Prize pool display with live updates
- Dynamic countdown timer
- Theme switching functionality
-
MessageBoard (
components/messageBoard.tsx)- Real-time message display
- Message submission interface
- Transaction status indicators
- Message history with infinite scroll
-
GameStats (
components/gameStats.tsx)- Current prize pool tracking
- Active player count
- Time remaining display
- Message fee calculator
- 24-hour rolling time windows
- Dynamic fee structure (starting at $1, capped at $200)
- Automated prize pool distribution
- Message verification and validation
- Historical context maintenance (50k+ tokens)
- Initial pool: $300
- Distribution: 75% to prize pool, 25% to treasury
- Exponential growth until fee cap
- Linear growth after fee cap
// GET /api/game/state
interface GameState {
prizePool: number;
lastMessageTime: number;
messageCount: number;
currentFee: number;
timeRemaining: number;
}// POST /api/game/message
interface SubmitMessage {
message: string;
signature: string;
timestamp: number;
walletAddress: string;
}// POST /api/auth/login
interface AuthRequest {
walletAddress: string;
signature: string;
}interface Message {
_id: ObjectId;
content: string;
walletAddress: string;
timestamp: Date;
gameId: string;
fee: number;
}interface Game {
_id: ObjectId;
startTime: Date;
prizePool: number;
status: 'active' | 'completed' | 'timedOut';
messageCount: number;
lastMessageTime: Date;
}- Node.js 16+
- MongoDB
- Solana CLI tools
# Install dependencies
npm install
# Setup environment
cp .env.example .env
# Run development server
npm run dev
# Build for production
npm run build# MongoDB connection string
MONGODB_URI=mongodb://...
# Solana RPC endpoints
SOLANA_RPC_URL=https://api.devnet.solana.com
NEXT_PUBLIC_SOLANA_RPC_URL=https://api.devnet.solana.com
# Wallet configuration
TREASURY_WALLET=your_treasury_wallet_private_key
NEXT_PUBLIC_TREASURY_WALLET_PUBKEY=your_treasury_wallet_public_key
# Authentication
JWT_SECRET=your_jwt_secret_key
# External APIs
GARY_API_URL=https://api.gary.example.comconst handleMessage = async (message: string) => {
const response = await fetch(process.env.GARY_API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
message,
context: lastMessages,
}),
});
return response.json();
};-
User Connection
- Connect Solana wallet
- Verify wallet balance
- Generate JWT token
-
Message Submission
- Calculate current fee
- Verify sufficient balance
- Process transaction
- Store message in MongoDB
- Update game state
-
Prize Distribution
- Monitor game conditions
- Validate winning conditions
- Process prize transfer
- Update game status
- Double-submission prevention
- Rate limiting per wallet
- Input sanitization
- Signature verification
- JWT authentication
- Rate limiting
- CORS configuration
- Request validation
- WebSocket integration for real-time updates
- Enhanced analytics dashboard
- Mobile-responsive design improvements
- Performance optimization for high-load scenarios
- Multiple concurrent games
- Social features (user profiles, chat)
- Achievement system
- Historical leaderboards
MIT License