Livestream Server

The 24/7 automated raffle system.

Overview

Located at apps/livestream/server, this Node.js daemon runs continuously to:

  • Schedule hourly raffles
  • Snapshot token holders
  • Select winners via TEE randomness
  • Transfer NFTs to winners
  • Post announcements to social media

Key Components

Core (core/)

  • agent.ts - Main application initialization
  • scheduler.ts - Cron-based raffle scheduling
  • websocket.ts - WebSocket server for stream overlay

Raffle (raffle/)

  • manager.ts - Complete raffle lifecycle orchestration
  • selection.ts - Winner selection with TEE randomness
  • snapshot.ts - Token holder snapshots via RPC

Twitch (twitch/)

  • chat-monitor.ts - Free entry system for legal compliance

Social (social/)

  • twitter.ts - Winner announcements

Running Locally

cd apps/livestream/server
pnpm dev

Environment Variables

Required variables in .env:

  • HELIUS_RPC_URL - Solana RPC endpoint
  • MISS_TOKEN_MINT - $MYS token mint address
  • AGENT_WALLET_PRIVATE_KEY - Agent wallet for signing
  • TEE_RANDOMNESS_ENDPOINT - TEE randomness service URL
  • TEE_VAULT_ENDPOINT - TEE vault service URL
  • TEE_VAULT_API_KEY - Vault service authentication

Raffle Cycle

  1. Snapshot token holders at :00
  2. Open 5-min free entry window on Twitch
  3. Generate verifiable random seed via TEE
  4. Select winner (token holders + chat entries)
  5. Transfer NFT to winner via TEE vault
  6. Announce winner on Twitter

Next Steps