Helius

1/17/2023 7:23:47 PM

Tutorial: No-code Solana Discord Bot

no-code.png

Introduction

A year ago, I published a blog post on how to write a sales bot for Solana. You can find the blog post here.

A common issue with it was that it was difficult for people with no coding experience to set up.

To remedy this, I’ve created a no-code solution for easily creating Discord bots that can listen to any kind of transaction — including NFT listings, NFT Bids, Solana transfers, and 70+ other built-in transaction types.

Prerequisites (2 minutes)

There are only three prerequisites for this tutorial:

  1. Creating a Helius API Key
  2. Creating a Replit account
  3. Creating a Discord Webhook URL

To create a Helius API key, simply go to dev.helius.xyz, connect your Solana wallet and click “Generate API Key”.

convert.png

To create a Replit account, go to replit.com and follow the instructions.

To create a Discord webhook URL, go to your Discord server, click Server Settings -> Integrations -> Webhooks. You can then click “Copy Webhook URL”. Discord also provides more detailed instructions here.

Creating the Bot

To create the bot, click on this Replit template, click “Edit Template” and then click “Fork Repl”.

You will now see a template for a bot that looks like the following:

1*Xmz0_-SqjvAylqkSsaTI8g.webp

For example, the URL of the server is: https://DiscordBotTemplate-1.mertmumtaz1.repl.co

On line 7, go ahead and paste the Discord webhook URL that you created in the Prerequisites section.

Finally click the run button at the top. You will then see a URL on the top right of the Replit console which shows the URL of your server (see image below). Copy this URL.

1*kVEHXaJz2E_eGhLAS-ifUQ.webp

To finish it off, go to dev.helius.xyz, click “Webhooks” and then “Create Webhook”.

In the webhook portal, select the type of transactions you want your bot to report (NFT_SALE for example) in transaction types.

Then copy and paste your Replit URL’s server, followed by “/discord”. For the above example, this would be: “https://DiscordBotTemplate-1.mertmumtaz1.repl.co/discord”

Input the account addresses of the marketplace(s) that you’d like to listen to. For this example, we’ll just use Magic Eden (M2mx93ekt1fmXSVkTrUL9xVFHkmME8HTUi5Cyc5aF7K).

Finally, click “Create Webhook”.

1*9VcucXccZS9gyJSgYlOpCA.webp

In about 1–2 minutes, you will see events being posted to the Discord channel that you created the webhook for!

Next Steps

If you’ve made it this far, I’d recommend for you to modify the format of your Discord message to make it look nicer. For example, you can call our metadata endpoint and enrich the events with the actual NFT image.