Guest written by Community builder Patrick Gallagher
Discord and Telegram are the best places for tech-savvy teams or communities to chat. And with any new communication platform, we need a way to isolate the signal from the noise.
To solve this, we built Swordy Bot. The bot is integrated with Unlock Protocol, so you can limit access to only community members who hold a specific Lock token (NFT). Best of all, its completely automated!
If the user doesn't have the necessary Lock token in their wallet, they are directed to the Unlock Protocol app, where they can purchase one.
Big thank you to the Unlock Protocol for sponsoring this bounty. Working with the team has been a breeze, and its really cool that they support people who want to build with their protocol. If you're a developer, I definitely would recommend looking at their other bounties.
How it works
It uses complicate machine learning... just kidding! It's actually pretty simple. The bot checks the user's wallet for the appropriate key to the Lock. If they have it, then the user earns the appropriate roles.
The basic steps for setting up the bot are:
Step 1. Add the bot to your server at swordybot.com
Step 2. Add the requirements for a role using
Step 3. Users can get access using the
If successful you'll see a message like this, giving you some new roles:
How I built it
Integrating with Unlock Protocol was extremely simple. The magic all happens in this one line of code where I call the
getHasValidKey function on the appropriate contract.
const hasValidKey = await lockContract.getHasValidKey(userAddress)
If you're interested in building your own bot, or building with Unlock, most of the code for Swordy Bot is available here.
We are super excited to continue building. Let us know what you want to see and give us feedback in our Discord
If you like where we are headed, consider follow @swordybot