This is where the code for Verified Ohmies lives, both frontend and backend. Verified Ohmies is a Discord bot that enables Discord users to prove they own Olympus tokens by signing a message with their wallet, and get a Discord role after successful authentication.
This is similar to what collab.land does for NFT’s, but here we have the added twist that we need to track several different tokens on several different chains.
- Reduce the scamming attack surface on our Discord. Users can immediately verify who is a real Ohmie by checking whether they have the verification role.
- Exclusive channels for Olympus token owners could be created.
- Obtaining and keeping the verified role would be another incentive for Ohmies to keep doing (3,3).
- This would also open other avenues, such as enabling the creation of polls on Discord where only verified Ohmies could vote, such that the weight of their vote would be proportional to how many Olympus tokens they own.
- Expected Outcomes
- Make our Discord safer and scammer-free.
- Further encourage (3,3) by attributing a verified role.
- Reinforce the trust between Ohmies.
- Measurable Objectives
- The number of Ohmies on our Discord using the bot to authenticate themselves on a monthly basis.
- The amount of scammer reports we’re getting on the server - the harder scammers’ life is, the less they’ll hang out on our Discord and look for lower hanging fruits.
- The aim is to have v1 ready around the end of January 2022. This version will include only gOHM on Ethereum Mainnet.
- Taking what we learn from v1, we will incrementally add the rest of the Olympus tokens and the other chains.
After setup, run the following command /verified
Initial setup for deployment is a little complicated, so is being documented here:
- Create Discord servers
- One server is required for both production and staging
- Note the server ID of each
- Create the Discord role you want to give the user after they've authenticated with Ethereum. For example,
verified
.- One role should be created on each of the servers
- Note the role ID of each (and which server it belongs to)
- Important: this role must be lower in the hierarchy than the one for the bot you create in the next step, otherwise you'll get a "missing access" error. See here how to move a role up or down in the hierarchy.
- Create the application for your bot
- One application should be created on each of the servers
- [Instructions]https://discordjs.guide/preparations/setting-up-a-bot-application.html#creating-your-bot
- Select the following boxes in the OAuth2 -> URL Generator tab. Open the link marked in red and choose your server to add the bot.
- Note the app ID, bot token and public key of each (and which server it belongs to)
- Set secrets in the GitHub repo. All deployments will use these secrets by default, so avoid using any instances that have production data that could be modified.
ALCHEMY_MAINNET_API_KEY
:ALCHEMY_RINKEBY_API_KEY
:COVALENTHQ_API_KEY
:DISCORD_APP_ID
:DISCORD_BOT_TOKEN
:DISCORD_PUBLIC_KEY
:DISCORD_ROLE_ID
: Right-click your server on Discord -> Server Settings -> Roles -> "...". There may be a role already created by the bot integration, but that likely won't work, and you'll need to create a new role.DISCORD_SERVER_ID
: Right-click your server on Discord and select Copy ID to get thisHASURA_ADMIN_SECRET
:HASURA_ENDPOINT
:INFURA_PROJECT_ID
:JWT_EXPIRATION_TIME
: Recommended: 1dJWT_SECRET
: the JWT secret shared between the backend and discord.node -e "console.log(require('crypto').randomBytes(256).toString('base64'));"
MORALIS_API_KEY
: Click on your profile picture (top-right), then "API", then copy the value next to "Web3 API Key"VERCEL_BACKEND_PROJECT_ID
: The Vercel project ID for the backendVERCEL_DISCORD_PROJECT_ID
: The Vercel project ID for the Discord botVERCEL_FRONTEND_PROJECT_ID
: The Vercel project ID for the frontendVERCEL_ORG_ID
: The Vercel org IDVERCEL_TOKEN
:VERCEL_TEAM_ID
: The Vercel team ID (same as org)
- Set secrets for the production environment
- Create the production environment and restrict to the
main
branch: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#environment-secrets - On the environments screen, add entries under the "environment secrets" section with production values.
DISCORD_APP_ID
DISCORD_BOT_TOKEN
DISCORD_PUBLIC_KEY
DISCORD_ROLE_ID
DISCORD_SERVER_ID
HASURA_ADMIN_SECRET
HASURA_ENDPOINT
- Create the production environment and restrict to the
- Deploy the stack
- Merging a pull request into the
main
ordevelop
branches will result in a production and staging deployment, respectively. - Pull requests into
main
anddevelop
will also result in "preview" deployments.
- Merging a pull request into the
- Set interactions URL
- After deployment, the interactions URL in Discord can be set (for each app).
- URL values:
- Production:
https://verified-ohmies-discord.vercel.app/api/command-interactions
- Staging:
https://verified-ohmies-discord-staging.vercel.app/api/command-interactions
- Other branches: copy the URL from the Vercel deployment for the discord project, and append
/api/command-interactions
- Production:
- Follow these steps:
- Visit the applications in the developer portal: https://discord.com/developers/applications
- Select the app created
- Select "General Information" in the sidebar
- Enter the domain in the "Interactions Endpoint URL" field, in the format:
https://<domain>/api/command-interactions
- Click "Save Changes".
Manual deployments are supported through GitHub Actions:
- Select on the deployment in the left-hand list
- Select the branch to deploy on
- Hit "Run workflow"