A Discord bot that verifies Unique Network wallet ownership and provides NFT-based perks and roles.
- 🔐 Wallet Verification: Verify Unique Network wallet ownership through micro-transactions
- 🖼️ NFT Detection: Automatically detect and verify NFT holdings
- 🎭 Role Management: Assign Discord roles based on verification status and NFT ownership
- ⏰ Time-based Verification: 60-minute verification windows with automatic cleanup
- 🛡️ Admin Controls: Admin-only commands for role configuration
- 📊 Status Tracking: Check verification status and NFT holdings
-
Wallet Verification Process:
- User runs
/verifyunq <address>command - Bot validates the Unique Network address format
- Bot requests a micro-transaction (0.001 UNQ) to the same address
- User transfers the exact amount to themselves
- Bot verifies the transaction on-chain
- Upon successful verification, user receives verification role
- User runs
-
NFT-based Perks:
- Verified users can run
/checknftsto scan their NFT holdings - Bot detects all NFTs owned by the verified address
- Additional roles/perks can be assigned based on specific collections or token IDs
- Verified users can run
/verifyunq <address>- Start wallet verification process/checknfts [address]- Check NFT holdings (address optional if already verified)/status- Check your verification status and perks
/admin-setrole <role>- Set the verification role (Admin only)
- Node.js 16+
- npm or yarn
- Discord Bot Token
- Unique Network RPC endpoint access
-
Clone the repository:
git clone <repository-url> cd Unique-Network-Asset-Gating-Bot
-
Install dependencies:
npm install
-
Create environment file:
cp env.example .env
-
Configure environment variables:
# Discord Bot Configuration DISCORD_TOKEN=your_discord_bot_token_here DISCORD_CLIENT_ID=your_discord_client_id_here DISCORD_GUILD_ID=your_discord_guild_id_here # Unique Network Configuration UNIQUE_NETWORK_ENDPOINT=wss://ws.unique.network UNIQUE_NETWORK_CHAIN_ID=unique # Bot Configuration VERIFICATION_AMOUNT=0.001 VERIFICATION_TIMEOUT_MINUTES=60 ADMIN_USER_ID=your_admin_user_id_here # Database Configuration DATABASE_PATH=./data/bot.db
-
Create data directory:
mkdir -p data
-
Start the bot:
npm start
-
Create a Discord Application:
- Go to Discord Developer Portal
- Create a new application
- Go to the "Bot" section and create a bot
- Copy the bot token
-
Invite the Bot:
- Go to OAuth2 > URL Generator
- Select "bot" scope
- Select required permissions:
- Send Messages
- Use Slash Commands
- Manage Roles
- Read Message History
- Use the generated URL to invite the bot
-
Configure Bot Permissions:
- Ensure the bot has permission to manage roles
- The bot role should be higher than the roles it needs to assign
- Discord Bot Service (
src/services/discordBot.js): Handles Discord interactions and commands - Unique Network Service (
src/services/uniqueNetwork.js): Manages blockchain interactions - Database Service (
src/config/database.js): SQLite database for user data and verification tracking
- users: Stores user verification status and wallet addresses
- nft_verifications: Tracks verified NFT holdings
- verification_attempts: Manages active verification sessions
Set the verification amount in the .env file:
VERIFICATION_AMOUNT=0.001Configure verification timeout:
VERIFICATION_TIMEOUT_MINUTES=60Customize NFT role assignment in src/services/discordBot.js:
async applyNFTRoles(guild, discordId, nfts) {
// Implement your custom logic here
// Example: Assign roles based on collection IDs
for (const nft of nfts) {
if (nft.collectionId === 123) {
// Assign special role for collection 123
}
}
}- Micro-transaction Verification: Uses small amounts to prevent abuse
- Time-limited Sessions: Verification attempts expire automatically
- Address Validation: Validates Unique Network address format
- Transaction Verification: Confirms transactions on-chain
- Admin-only Commands: Sensitive operations require admin privileges
-
Bot not responding to commands:
- Check bot permissions in Discord
- Verify bot token is correct
- Ensure bot is online
-
Verification failing:
- Check Unique Network connection
- Verify transaction amount matches exactly
- Ensure transaction is to the same address
-
Database errors:
- Check data directory permissions
- Verify database path in environment
The bot provides detailed console logs for debugging:
- Connection status
- Command processing
- Verification attempts
- Error details
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details
For issues and questions:
- Create an issue on GitHub
- Check the troubleshooting section
- Review Discord.js and Unique Network documentation
- Webhook notifications for verification events
- Advanced NFT filtering and role assignment
- Multi-chain support
- Analytics dashboard
- Automated role cleanup
- Integration with other blockchain networks