Inspiration

Inspired by Collab.land and the rapid growth of Near community on discord, this bot was created to help people build token gated communities on discord. We would like to take the advantage of both Near's blockchain technology and Discord's well-designed management tools and instant messages to better help the Nearian communities to grow and expand. Our mission is to facilitate community management across Near ecosystem, and hope to onboard more people to Near protocol via token gated experience.

What it does

Nepbot is designed for anyone who wants to build and manage their tokenized communities on Discord based on Near and NEP141 token holdings. It’s safe to use and easy to get started with simple and intuitive commands. By connecting one’s discord account to Near wallet, and setting up token-gated discord roles, community members can verify their identity and assets on Near and therefore gain access to specific contents. After being invited to a Discord server and authorized as an "administrator", the bot can automatically manage roles based on the token holdings and staking status. Server members can connect their Discord account to their Near wallets and get verified by entering “!oauth” in the chat. A server owner can set token rules for different roles in a server with the command “!setrule”, then the bot will periodically check if the verified accounts meet the rules, and assign them roles accordingly. If the users no longer meet the conditions of the rule due to transactions, they will be automatically removed from the corresponding roles.

How we built it

We built it in Discord Developer Portal, with the following components: Components: Nep bot backend(node.js), a smart contract on Near to record the rules (Rust), Nepbot web frontend(React), a database to record discord user ID, discord guild ID, discord role ID, Near wallets, and attributes of rules, including token ID, token amount, Near balance, and staking status.(MySQL) Technical specs: Discord.js, Node.js, Near-indexer-for-explorer, Near-api-js, oauth2, MySQL Final Deliverable: A discord bot that can be invited to any discord server, and an official website for the bot: nepbot.org. Below are references for us when making this bot: https://discordjs.guide/https://github.com/near/near-indexer-for-explorerhttps://discord.com/developers/docs/intro

Challenges we ran into

After successfully connect discord accounts to Near wallet, we could view and fetch the balance in near wallets, and link discord accounts to Near wallets, but we soon came across two major issues as below:

  1. How to monitor the balance and status in all verified accounts? We set up an off-chain database to keep record of discord IDs, token ID and wallet addresses. Then, set a query loop that will regularly check the transactions on Near Protocol and on verified tokens. The bot will record the balance in each Near wallet at the time of the first verification, and later on, change the balance based on the transactions. This enables continuous balance monitoring, while at the same time can reduce server stress to some extent.
  2. If role sets are off-chain, how to ensure their reliability? We have finally decided to save the role sets in the smart contract, which has ensured both its security and transparency. By putting them on chain, it would be impossible for others to falsify the rules, and it also allows other websites to get the role sets with discord account authorization or even modify them directly on the web.

Accomplishments that we're proud of

  1. Build a bot that links web2 and web3 identity with Near Protocol tokens-based communities on Discord
  2. Be the first Discord bot that allows users to manage their discord communities based on NEP token and Near holdings and created token-gated channels with simple and intuitive commands.
  3. Safe and secure. Nepbot will only be authorized to view your account, and will never start any transaction with permissions. Rules are saved on chain with smart contract and can only be modified by the server owner.
  4. The bot is designed for all. It’s open-sourced, accessible for all, and completely free to use.
  5. Hopefully, it will help tokens holders to form communities and serve as a DAO tools across Near ecosystem.

What we learned

  1. How Near indexer service works
  2. Discord design and rules
  3. NEP-141 standards
  4. Structure of Octopus Smart Contract

What's next for Nep Bot

  1. Launch on Near Mainnet
  2. Support verification of Near staking status
  3. Verify Twitter identity on discord
  4. Connect to other social media platforms on discord
  5. Enter !help to call out Command lists
  6. Check Balances in Near wallet
  7. Verify NFTs (NEP 171) holdings
  8. Check NEP-141 token prices
  9. Send and claim airdrops
  10. Optimize interactions
  11. Setup a snapshot
  12. Create a poll (on/off chain)

Built With

Share this project:

Updates