A powerful Discord token-gating bot that allows creators to gate access to channels, roles, and content using cryptographic tokens, NFTs, or access passes.
- Token & NFT Verification: Verify wallet ownership via Web3 connections
- Automatic Role Assignment: Auto-assign Discord roles based on token/NFT ownership
- Multi-Chain Support: Ethereum, Polygon, BSC, Avalanche
- Real-time Analytics: Track verification success rates and usage
- Web Dashboard: Easy-to-use interface for configuration
- Event Pass Validation: Check passes for timed events
- Audit Logs: Complete verification history
- ERC-20 Tokens: Minimum balance requirements
- ERC-721 NFTs: Collection ownership verification
- ERC-1155 Tokens: Multi-token standard support
- Go to Discord Developer Portal
- Create a new application
- Go to "Bot" section and create a bot
- Copy the bot token
- Go to "OAuth2" β "General" and add your redirect URL:
https://your-app.onrender.com/auth/callback
- Copy Client ID and Client Secret
- Fork this repository
- Connect your GitHub account to Render
- Create a new Web Service from your forked repo
- Set the following environment variables:
DISCORD_BOT_TOKEN=your_bot_token_here
DISCORD_CLIENT_ID=your_client_id_here
DISCORD_CLIENT_SECRET=your_client_secret_here
DISCORD_REDIRECT_URI=https://your-app.onrender.com/auth/callback
WEB_URL=https://your-app.onrender.com
Use this URL (replace YOUR_CLIENT_ID):
https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=268435456&scope=bot%20applications.commands
Required Permissions:
- Manage Roles
- Read Messages
- Send Messages
- Use Slash Commands
- Visit your deployed app URL
- Login with Discord
- Select your server
- Add token gates with contract addresses and role IDs
/verify [wallet_address]
- Verify wallet and get roles/status
- Check your verification status
/setup
- Get setup instructions and dashboard link
Variable | Description | Required |
---|---|---|
DISCORD_BOT_TOKEN |
Your Discord bot token | Yes |
DISCORD_CLIENT_ID |
Discord application client ID | Yes |
DISCORD_CLIENT_SECRET |
Discord application client secret | Yes |
DISCORD_REDIRECT_URI |
OAuth2 redirect URI | Yes |
DATABASE_URL |
Database connection string | No (defaults to SQLite) |
WEB_URL |
Your app's public URL | Yes |
ETHEREUM_RPC |
Ethereum RPC endpoint | No (default provided) |
POLYGON_RPC |
Polygon RPC endpoint | No (default provided) |
BSC_RPC |
BSC RPC endpoint | No (default provided) |
AVALANCHE_RPC |
Avalanche RPC endpoint | No (default provided) |
GET /
- Dashboard (requires login)GET /login
- Login pageGET /auth/callback
- OAuth2 callbackGET /logout
- Logout
GET /server/{server_id}
- Server configuration pagePOST /api/token-gate
- Create new token gateGET /api/analytics/{server_id}
- Get server analytics
POST /api/verify-wallet
- Verify wallet ownershipGET /api/user/profile
- Get user profile
- Python 3.9+
- Discord Bot Token
- Discord Application (Client ID & Secret)
- Clone the repository
git clone <your-repo-url>
cd opal-discord-bot
- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies
cd backend
pip install -r requirements.txt
- Create environment file
cp .env.example .env
# Edit .env with your values
- Run the application
python main.py
The bot and web dashboard will start on http://localhost:8000
backend/
βββ main.py # FastAPI application & Discord bot startup
βββ bot.py # Discord bot commands and events
βββ database.py # Database configuration
βββ models.py # SQLAlchemy models
βββ services/
β βββ discord_oauth.py # Discord OAuth2 implementation
β βββ token_verification.py # Web3 token verification
β βββ analytics.py # Analytics service
βββ templates/ # Jinja2 HTML templates
βββ static/ # CSS and static assets
Chain | Chain ID | RPC Endpoint |
---|---|---|
Ethereum | 1 | https://eth.llamarpc.com |
Polygon | 137 | https://polygon.llamarpc.com |
BSC | 56 | https://bsc-dataseed.binance.org |
Avalanche | 43114 | https://api.avax.network/ext/bc/C/rpc |
- Basic verification for 1 token gate per server
- Up to 100 verifications/month
- Community support
- Up to 10 token gates per server
- Unlimited verifications
- Custom role mappings
- Priority support
- Unlimited token gates
- White-label branding
- Custom integrations
- Dedicated support
- Analytics dashboard
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Documentation: Check this README and inline code comments
- Issues: Use GitHub Issues for bug reports
- Discord: Join our support server (link in bio)
- Email: [email protected]
This project is licensed under the MIT License - see the LICENSE file for details.
- Multi-server management
- Custom webhook integrations
- Scheduled token verification
- Mobile app companion
- Advanced analytics dashboard
- Integration with more chains (Solana, etc.)
- Subscription management via Stripe
Built with β€οΈ for Web3 communities by the Opal team.