A token verification system for Discord that grants roles based on Solana token holdings. This project consists of two main components:
- Web Application (
work-verify): A Next.js application that connects to users' Solana wallets to verify token holdings. - Discord Bot (
work-discord-bot): A Discord bot that manages verification requests and assigns roles based on token holdings.
This project allows Discord server administrators to create token-gated roles, where users must hold a specific amount of a Solana token to receive a special role. The system:
- Verifies wallet ownership through cryptographic signatures
- Checks token balances on the Solana blockchain
- Assigns Discord roles based on token holdings
- Periodically checks balances to add/remove roles as needed
- Stores user data in a Supabase database
The web application is deployed at: https://verify-bot-zeta.vercel.app/
Note: You'll need a verification code from the Discord bot to use the application.
- Node.js (v18 or higher)
- pnpm (v10 or higher)
- Discord Bot Token and Application
- Supabase Account and Project
- Solana RPC URL (from providers like Helius, QuickNode, or Alchemy)
git clone https://github.com/gibwork/verify-bot.git
cd verify-botcd work-verify
# Install dependencies
pnpm install
# Create .env file from example
cp .env.example .envEdit the .env file with your configuration:
NEXT_PUBLIC_VERIFY_API_ENDPOINT=http://localhost:3001/api/verify-wallet
SOLANA_RPC_URL=your_solana_rpc_url
cd ../work-discord-bot
# Install dependencies
pnpm install
# Create .env file from example
cp .env.example .envEdit the .env file with your configuration:
DISCORD_TOKEN=your_discord_bot_token
CLIENT_ID=your_discord_application_id
GUILD_ID=your_discord_server_id
ROLE_ID=your_role_id
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_key
SOLANA_RPC_URL=your_solana_rpc_url
CLIENT_URL=http://localhost:3000
PORT=3001
The project uses Supabase as its database. Follow these steps to set up your database:
- Create a Supabase project at supabase.com
- In the Supabase dashboard, go to the SQL Editor
- Create a new query and paste the following SQL to create the required table:
CREATE TABLE holders (
id SERIAL PRIMARY KEY,
username TEXT NOT NULL,
discord_user_id TEXT UNIQUE NOT NULL,
address TEXT[] NOT NULL,
active BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);- Run the query to create the table
- Copy your Supabase URL and anon key from the Settings > API section to use in your
.envfile
- Start the web application:
cd work-verify
pnpm dev- Start the Discord bot:
cd work-discord-bot
pnpm dev- Build and start the web application:
cd work-verify
pnpm build
pnpm start- Build and start the Discord bot:
cd work-discord-bot
pnpm build
node dist/index.js- Invite the bot to your Discord server
- Use the
/verifycommand in your server - Click the "Connect Wallet" button
- Connect your Solana wallet on the verification page
- Sign the message to prove wallet ownership
- If you have the required token balance, you'll receive the role
The token address and required balance are defined in both applications:
-
In
work-verify/components/VerifyContent.tsx:const SPECIFIC_TOKEN_MINT = "F7Hwf8ib5DVCoiuyGr618Y3gon429Rnd1r5F9R5upump"; const REQUIRED_BALANCE = 200000;
-
In
work-discord-bot/src/index.ts:const TOKEN_MINT_ADDRESS = "F7Hwf8ib5DVCoiuyGr618Y3gon429Rnd1r5F9R5upump"; const REQUIRED_BALANCE = 200000;
To change the token or required balance, update these values in both files.
Contributions are welcome! Here's how you can contribute:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -am 'Add new feature' - Push to the branch:
git push origin feature/my-feature - Submit a pull request
Please make sure to update tests as appropriate and follow the code style of the project.
app/: Next.js app directorypage.tsx: Main page componentlayout.tsx: Root layout componentapi/: API routes
components/: React componentsVerifyContent.tsx: Main verification componentWalletProvider.tsx: Solana wallet adapter provider
src/: Source codeindex.ts: Main bot application
-
Discord Bot Not Responding
- Check if your bot token is correct
- Ensure the bot has the necessary permissions
-
Wallet Connection Issues
- Make sure you're using a supported Solana wallet
- Check if your RPC URL is valid and has sufficient rate limits
-
Role Not Being Assigned
- Verify that the bot has permission to manage roles
- Check if the role ID in the .env file is correct
- Ensure the bot's role is higher than the role it's trying to assign