Skip to content

luxfi/web

Repository files navigation

Lux Web - Voting & Governance Platform

Web3 Voting Interface for Lux DAO

A modern, quantum-ready web platform for participating in Lux network governance.

Features

Voting Interface

  • Proposal Browser: View and filter active/past proposals
  • Voting Dashboard: Cast votes with hardware wallet support
  • Delegation UI: Delegate voting power to representatives
  • Analytics: Real-time voting statistics and trends

Quantum Integration

  • Multi-Chain Voting: Vote across Lux/Hanzo/Zoo from one interface
  • AI-Powered Insights: LLM analysis of proposal impacts
  • MCP Integration: Use AI agents to analyze proposals
  • Predictive Analytics: ML models for outcome prediction

Lux Ecosystem Integration

Core Platforms

  • Lux Network: Foundation of the quantum blockchain ecosystem
  • Lux Bridge: Cross-chain asset transfers with zkProof privacy
  • Lux Explorer: Transaction and block explorer
  • Lux Wallet: Wallet and validator management
  • Lux Credit: Zero-interest, auto-repaid credit card
  • Lux Exchange: Cryptocurrency and NFT trading
  • Lux Market: Real-world asset tokenization (gold, silver)
  • Lux Safe: Quantum-safe multisig wallet
  • Lux AI: AI assistant for ecosystem navigation
  • Lux Shop: Purchase blockchain essentials

Tech Stack

Frontend

  • Framework: Next.js 14 with App Router
  • Styling: Tailwind CSS + Radix UI
  • State: Zustand + TanStack Query
  • Web3: Wagmi + Viem + RainbowKit
  • Charts: Recharts for analytics
  • Icons: Lucide icons
  • Dark Mode: next-themes

Backend

  • API: tRPC with Next.js API routes
  • Database: PostgreSQL with Prisma
  • Caching: Redis for vote aggregation
  • Indexing: The Graph for on-chain data

Smart Contract Integration

// hooks/useLuxDAO.ts
import { useContractWrite, useContractRead } from 'wagmi'
import { LuxDAOABI } from '@/contracts/abi'

export function useLuxDAO() {
  const { data: proposals } = useContractRead({
    address: LUX_DAO_ADDRESS,
    abi: LuxDAOABI,
    functionName: 'getActiveProposals'
  })

  const { write: vote } = useContractWrite({
    address: LUX_DAO_ADDRESS,
    abi: LuxDAOABI,
    functionName: 'vote'
  })

  return { proposals, vote }
}

Pages

/ - Dashboard

  • Active proposals overview
  • Your voting power
  • Delegation status
  • Recent activity

/proposals - Proposal List

  • Filter by status/category
  • Search proposals
  • Voting timeline
  • Participation metrics

/proposals/[id] - Proposal Detail

  • Full proposal description
  • Voting interface
  • Discussion thread
  • Impact analysis
  • Vote breakdown

/delegate - Delegation

  • Browse delegates
  • Delegate profiles
  • Voting history
  • Performance metrics

/analytics - Governance Analytics

  • Participation trends
  • Voting patterns
  • Proposal success rates
  • Token distribution

/create - Create Proposal

  • Proposal builder
  • Template library
  • Simulation tools
  • Cost calculator

Components

// components/VoteCard.tsx
export function VoteCard({ proposal }: { proposal: Proposal }) {
  const { vote, isLoading } = useVote(proposal.id)

  return (
    <Card>
      <CardHeader>
        <CardTitle>{proposal.title}</CardTitle>
        <Badge>{proposal.status}</Badge>
      </CardHeader>
      <CardContent>
        <p>{proposal.description}</p>
        <VotingProgress
          for={proposal.votesFor}
          against={proposal.votesAgainst}
          quorum={proposal.quorum}
        />
      </CardContent>
      <CardFooter>
        <Button onClick={() => vote(true)} disabled={isLoading}>
          Vote For
        </Button>
        <Button onClick={() => vote(false)} variant="outline">
          Vote Against
        </Button>
      </CardFooter>
    </Card>
  )
}

AI Integration

Proposal Analysis

// services/ai-analysis.ts
import { LuxAI } from '@luxfi/ai-sdk'

export async function analyzeProposal(proposal: Proposal) {
  const ai = new LuxAI()

  const analysis = await ai.analyze({
    type: 'proposal_impact',
    data: {
      title: proposal.title,
      description: proposal.description,
      actions: proposal.actions
    }
  })

  return {
    summary: analysis.summary,
    risks: analysis.risks,
    benefits: analysis.benefits,
    recommendation: analysis.recommendation
  }
}

MCP Tools

// mcp/governance-tools.ts
export const governanceTools = {
  analyzeVotingPower: async (address: string) => {
    // Analyze voting power distribution
  },

  predictOutcome: async (proposalId: number) => {
    // ML prediction of voting outcome
  },

  suggestDelegates: async (preferences: Preferences) => {
    // AI-powered delegate recommendations
  }
}

Development

Installation

# Install pnpm if not already installed
npm install -g pnpm

# Install dependencies
pnpm install

# Run development server
pnpm dev

Environment Variables

# Network
NEXT_PUBLIC_LUX_RPC=https://api.lux.network
NEXT_PUBLIC_CHAIN_ID=96369

# Contracts
NEXT_PUBLIC_DAO_ADDRESS=0x...
NEXT_PUBLIC_TOKEN_ADDRESS=0x...

# API Keys
LUX_API_KEY=...
GRAPH_API_KEY=...

# Database
DATABASE_URL=postgresql://...
REDIS_URL=redis://...

# AI/ML
LUX_AI_ENDPOINT=https://ai.lux.cloud
LUX_AI_API_KEY=...

Docker

FROM node:20-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci

COPY . .
RUN npm run build

EXPOSE 3000

CMD ["npm", "run", "start"]

Deployment Commands

# Development
pnpm dev

# Production build
pnpm build
pnpm start

# Docker
docker build -t lux-web .
docker run -p 3000:3000 lux-web

# Deploy to Vercel
vercel --prod

Testing

// __tests__/voting.test.ts
describe('Voting', () => {
  it('should cast vote successfully', async () => {
    const { vote } = renderHook(() => useVote())

    await act(async () => {
      await vote(proposalId, true)
    })

    expect(mockContract.vote).toHaveBeenCalledWith(
      proposalId,
      true
    )
  })
})

Security

  • Wallet Security: Hardware wallet support via WalletConnect
  • Transaction Validation: All transactions verified client-side
  • Rate Limiting: API rate limits to prevent abuse
  • CORS: Strict CORS policies
  • CSP: Content Security Policy headers
  • Audit Trail: All votes logged and auditable
  • Post-Quantum Encryption: Quantum-safe cryptography for future security

Lux Network Features

  • Decentralized: High Nakamoto coefficient ensuring resilience
  • Consensus: Probabilistic leaderless consensus mechanism
  • Post-Quantum Encryption: Protection against quantum threats
  • zkPowered Bridge: Privacy-preserving cross-chain transfers
  • Quantum-Safe: Built for the quantum computing era

Architecture

Built on:

  • Next.js 14
  • Radix UI Primitives
  • Tailwind CSS
  • Hanzo React SDK (@hanzo/ui, @hanzo/auth, @hanzo/commerce)

Resources

License

MIT License - See LICENSE file for details

About

▼ on the World Wide Web.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 16