Skip to content

alexcolls/solucky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฐ Sโ˜‰Lucky

Website: dailywin.sol Account: ArrZMZh5heYyy4hWzcEXbV2wbxyHxf7rugEvFuNzE3LE

Decentralized Daily Lottery on Solana

Solana Vue.js Node.js Socket.IO

Connect your wallet, pick your lucky number, and watch the pot grow in real-time โœจ

Quick Start โ€ข Features โ€ข Architecture โ€ข Configuration


๐ŸŽฏ Overview

SOLucky is a fully decentralized, transparent daily lottery built on Solana. Every ticket is stored on-chain with complete fairness and verifiability. The platform features real-time updates, live statistics, and seamless wallet integration.

Why SOLucky?

  • ๐Ÿ”’ Trustless & Transparent - All tickets stored on-chain
  • โšก Real-time Updates - Watch the pot grow with Socket.IO
  • ๐ŸŒ Global Participation - Track players by country
  • ๐Ÿ’ฐ Live SOL/USD Pricing - Real-time market rates
  • ๐Ÿ“Š Historical Analytics - Complete draw history and stats
  • ๐ŸŽจ Beautiful UI - Modern design with Tailwind CSS

๐Ÿ— Architecture

graph LR
    A[๐Ÿ‘› Solana Wallet] --> B[๐ŸŽจ Vue 3 Client]
    B --> C[โšก Node.js + Socket.IO]
    C --> D[๐Ÿ˜ PostgreSQL]
    C --> E[โ›“๏ธ Solana Program]
    B --> E
Loading

Stack Components

Layer Technology Location
Smart Contract Rust + Anchor solotto/*/src/program/lib.rs
Backend Server Express + Socket.IO solotto/server/
Lottery dApp Vue 3 + Tailwind solotto/client/
Landing Page Vue 3 web/
Database PostgreSQL Remote/Local
Real-time Socket.IO Backend & Clients

Data Flow

1. User connects Solana wallet ๐Ÿ‘›
2. Client commits ticket (number + country) ๐ŸŽŸ๏ธ
3. Backend broadcasts update via Socket.IO ๐Ÿ“ก
4. On-chain ticket account created โ›“๏ธ
5. Stats aggregated in PostgreSQL ๐Ÿ“Š
6. Live updates pushed to all clients โšก

โœจ Features

๐ŸŽฎ Core Gameplay

  • ๐Ÿ” Solana Wallet Integration - Phantom, Solflare, and more
  • ๐ŸŽŸ๏ธ Ticket Commitment - Choose your lucky number (0-99)
  • ๐ŸŒ Country Tracking - Geographic distribution of players
  • โฐ Daily Draws - Reset at 00:00:00 UTC

๐Ÿ“Š Real-time Stats

  • ๐Ÿ’ฐ Live Pot Value - Updated in SOL and USD
  • ๐Ÿ‘ฅ Active Players - Connected users count
  • โœ… Verified Tickets - Total committed tickets
  • ๐Ÿ—บ๏ธ Global Map - Players by country

๐Ÿ’ป Technical Features

  • โšก Socket.IO - Sub-second update latency
  • ๐Ÿ“ˆ Chart.js Integration - Historical data visualization
  • ๐ŸŽจ Tailwind CSS - Responsive, modern UI
  • ๐Ÿ”„ Auto-rotation - Daily table creation at 08:00 UTC
  • ๐Ÿ’ฑ Live Ticker - Bitstamp SOL/USD feed

๐Ÿš€ Quick Start

Prerequisites

# Required
Node.js >= 16
npm or yarn
PostgreSQL >= 12

# Optional (for smart contract development)
Rust + Cargo
Solana CLI
Anchor Framework

Installation

# 1. Clone the repository
git clone https://github.com/yourusername/77.git
cd 77

# 2. Install root dependencies
npm install

# 3. Install backend dependencies
cd solotto/server
npm install

# 4. Install client dependencies
cd ../client
npm install

# 5. Install web landing dependencies
cd ../../web
npm install

Running Development Servers

# Terminal 1 - Backend Server (Port 5001)
cd solotto/server
node server.js

# Terminal 2 - Lottery Client (Port 8080)
cd solotto/client
npm run serve

# Terminal 3 - Landing Page (Port 8081)
cd web
npm run serve

โš™๏ธ Configuration

Backend Server .env

Create solotto/server/.env:

# Database
POSTGRE_URL=postgres://user:password@localhost:5432/solucky

# CORS
CLIENT_URL=http://localhost:8080

# Server
PORT=5001

Lottery Client .env

Create solotto/client/.env:

# Backend WebSocket
VUE_APP_SOCKET_ENDPOINT=http://localhost:5001

# Solana Cluster
VUE_APP_CLUSTER_URL=https://api.devnet.solana.com
# For mainnet: https://api.mainnet-beta.solana.com

# Program ID
VUE_APP_PROGRAM_ID=fH2j1AXaGr14kCroRseuetQsJmi6rij1NNqkBicdksr

Landing Page .env

Create web/.env:

VUE_APP_SOCKET_ENDPOINT=http://localhost:5001
VUE_APP_CLUSTER_URL=https://api.devnet.solana.com

๐Ÿ’ก Tip: Check .env.sample files in each directory for complete examples


๐Ÿ”ง Development

Smart Contract

Location: solotto/client/src/program/lib.rs

Instructions

Instruction Parameters Description
send_ticket owner, number: i32, country: String Create new ticket
delete_ticket - Delete single ticket
delete_tickets - Delete all user tickets
close - Close account and reclaim rent
force_defund - Safety mechanism for closed accounts

Ticket Account Structure

pub struct Ticket {
    pub owner: Pubkey,      // Wallet address
    pub timestamp: i64,     // Unix timestamp
    pub number: i32,        // Lucky number (0-99)
    pub country: String,    // ISO country code
}

Program ID: fH2j1AXaGr14kCroRseuetQsJmi6rij1NNqkBicdksr

Backend Server

Location: solotto/server/

Socket.IO Events

Event Direction Payload Description
getPOT Server โ†’ Client { sol: Number, usd: Number } Current pot value
getTickets Server โ†’ Client Array<Ticket> All active tickets
nVerified Server โ†’ Client Number Verified ticket count
nPlayers Server โ†’ Client Number Unique player count
getHistory Server โ†’ Client Array<Draw> Historical draws
userNumber Client โ†’ Server { number: Number, country: String } Commit ticket

Scripts

# Production
npm start

# Development (auto-reload)
npm run dev

Frontend Clients

Lottery dApp (solotto/client)

Main application with:

  • ๐ŸŽฎ Play panel (ticket submission)
  • ๐Ÿ’ฐ Pot display (SOL/USD)
  • ๐Ÿ“Š Statistics dashboard
  • ๐Ÿ“œ History viewer

Landing Page (web)

Marketing site with:

  • ๐ŸŽจ Hero section
  • ๐Ÿ‘› Wallet status
  • ๐Ÿ“ฑ Call-to-action

Common Commands

# Development server
npm run serve

# Production build
npm run build

# Linting
npm run lint

๐Ÿ—„๏ธ Database Schema

Daily Tables

Tables are auto-created at 08:00 UTC with format: _YYYY_MM_DD_

CREATE TABLE _2024_10_21_ (
    id SERIAL PRIMARY KEY,
    owner VARCHAR(44),
    number INT,
    country VARCHAR(2),
    timestamp BIGINT,
    verified BOOLEAN DEFAULT false
);

๐Ÿ› Troubleshooting

Socket Connection Issues

Problem: Client can't connect to Socket.IO server

Solutions:

  • โœ… Verify VUE_APP_SOCKET_ENDPOINT matches backend URL
  • โœ… Check CORS settings in solotto/server/server.js
  • โœ… Ensure backend server is running on correct port
  • โœ… Check firewall/network settings

Empty Pot/Metrics

Problem: No data displayed in UI

Solutions:

  • โœ… Verify PostgreSQL connection via POSTGRE_URL
  • โœ… Check if daily table exists (created at 08:00 UTC)
  • โœ… Inspect browser console for errors
  • โœ… Ensure backend has database permissions

Wallet Connection Errors

Problem: Can't connect Solana wallet

Solutions:

  • โœ… Check VUE_APP_CLUSTER_URL is valid RPC endpoint
  • โœ… Verify wallet adapter is properly installed
  • โœ… Test with different wallet (Phantom, Solflare, etc.)
  • โœ… Check browser console for adapter errors
  • โœ… Ensure wallet has SOL for transaction fees

Build Issues

Problem: npm install or build fails

Solutions:

  • โœ… Use Node.js 16 or higher
  • โœ… Clear node_modules and reinstall: rm -rf node_modules && npm install
  • โœ… Clear npm cache: npm cache clean --force
  • โœ… Check for node-gyp issues on Windows

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒฟ Create a feature branch (git checkout -b feature/amazing-feature)
  3. ๐Ÿ’พ Commit your changes (git commit -m 'โœจ Add amazing feature')
  4. ๐Ÿ“ค Push to the branch (git push origin feature/amazing-feature)
  5. ๐ŸŽ‰ Open a Pull Request

Guidelines

  • Ensure all linters pass before submitting
  • Write clear commit messages
  • Update documentation for new features
  • Test thoroughly on devnet before proposing mainnet changes

๐Ÿ“‹ Roadmap

  • ๐ŸŽจ UI/UX improvements
  • ๐Ÿ”” Push notifications for draws
  • ๐Ÿ“ฑ Mobile app (React Native)
  • ๐Ÿ† Leaderboard system
  • ๐ŸŽ Referral rewards
  • ๐ŸŒ Multi-language support
  • ๐Ÿ” Enhanced security audits
  • ๐Ÿ“ˆ Advanced analytics dashboard

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Solana Foundation for the amazing blockchain
  • Anchor Framework for smart contract development
  • Vue.js community for excellent tooling
  • Socket.IO for real-time communication

Built with โค๏ธ on Solana

โฌ† Back to Top

About

๐ŸŽฐ dailywin.sol a.k.a. Sโ˜‰Lucky: The Solana daily lottery.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors