Skip to content

mum33n/FairGate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

FairGate

A Discord bot and web application platform that provides reputation-based access control for Discord servers. FairGate integrates wallet verification with FairScale (a Solana-based reputation system) to enable custom tiered role assignments based on users' financial behavior and reputation scores.

Problem

Traditional Discord access control relies on static token holdings, which doesn't reflect user behavior, risk assessment, or reputation. FairGate solves this by enabling Discord servers to gate access and assign roles based on FairScale's reputation scores, creating a more nuanced and fair access control system.

Features

For Users

  • Wallet Linking - Connect your Solana wallet securely
  • Reputation Verification - FairScale reputation scores are fetched automatically
  • Automatic Role Assignment - Receive Discord roles based on your FairScore
  • Multi-Server Support - One wallet link works across all servers using FairGate
  • Read-Only Verification - No wallet transactions or fees required

For Server Admins

  • Tier Management - Create custom tiers with /tier add, /tier remove, /tier list
  • Role Configuration - Assign Discord roles to FairScore thresholds (0-1000)
  • Emoji Customization - Add emojis to tier names
  • Auto-Setup - Bot automatically creates setup and verification channels on join

Tech Stack

Backend

  • Node.js + Express.js
  • TypeScript
  • Discord.js
  • Prisma ORM + PostgreSQL
  • FairScale API Integration

Frontend

  • React 19
  • TypeScript
  • Vite
  • Tailwind CSS
  • Solana Wallet Adapter (Phantom, Solflare)

Project Structure

fairthon/
├── backend/
│   ├── src/
│   │   ├── api/          # REST API routes and services
│   │   ├── bot/          # Discord bot commands and events
│   │   ├── config/       # Configuration management
│   │   └── lib/          # Shared libraries (Prisma client)
│   └── prisma/           # Database schema
│
└── ui/
    └── src/
        ├── pages/        # React pages (Home, WalletLink)
        └── App.tsx       # Main application component

Getting Started

Prerequisites

  • Node.js (v18+)
  • PostgreSQL
  • Discord Application (Bot Token & Client ID)
  • FairScale API credentials

Environment Variables

Create .env files in both backend/ and ui/ directories.

Backend (backend/.env):

PORT=3000
NODE_ENV=development
API_URL=http://localhost:3000
APP_URL=http://localhost:5173

# Discord
DISCORD_TOKEN=your_discord_bot_token
DISCORD_CLIENT_ID=your_discord_client_id

# FairScale
FAIRSCALE_API_URL=https://api.fairscale.io
FAIRSCALE_API_KEY=your_fairscale_api_key

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/fairgate

# Service toggles
START_API=true
START_BOT=true

Frontend (ui/.env):

VITE_API_URL=http://localhost:3000

Installation

  1. Clone the repository:
git clone <repository-url>
cd fairthon
  1. Install backend dependencies:
cd backend
npm install
  1. Set up the database:
npx prisma generate
npx prisma db push
  1. Deploy Discord commands:
npm run deploy:commands
  1. Install frontend dependencies:
cd ../ui
npm install

Running the Application

Backend:

cd backend
npm run dev        # Run both API and bot
npm run dev:api    # Run API only
npm run dev:bot    # Run bot only

Frontend:

cd ui
npm run dev        # Development server at http://localhost:5173

Discord Bot Commands

Command Description
/ping Check bot latency
/tier add Add a new FairScore tier
/tier remove Remove an existing tier
/tier list View all configured tiers

API Endpoints

Method Endpoint Description
GET /api/health Health check
POST /api/link/ Create wallet link
GET /api/link/:userId Fetch wallet link
GET /api/verify/:guildId/:userId Show verification UI
GET /api/score?wallet=<address> Fetch FairScore for wallet

Database Schema

  • Guild - Discord server configuration and metadata
  • Tier - FairScore tiers with role mappings
  • WalletLink - User wallet to Discord ID associations

License

MIT

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages