Sneak-peek:
GitHub - Tidelaw/webhook-display: Create a UI for Helius's transaction webhook.
Webhooks are a critical component of web development today. It allows developers to receive real-time data about user activities on websites or apps. In this blog post, we will walk you through the process of creating a UI for Helius's transaction webhook.
A website that displays webhook data from Helius API for NFT-related transactions of any given wallet address. The website will use a webhook from Helius to receive real-time data, which will then be processed by an internal API. This API will store the data into the Supabase database, where it will be retrieved by another internal API and displayed to the user in real-time on every reload of the website. This means that users will be able to stay up-to-date with their NFT transactions, receiving notifications in real-time whenever new transactions occur.
In order to run locally:
npm install
to install all our project's dependenciesnpm run dev
to run our applicationnpm install
downloads the packages found in package.json
npm run dev
runs the website. The website can now be accessed from localhost:3000
or 0.0.0.0
In order for the dAPP to work, a webhook is necessary - in order to set one up, visit
https://www.helius.xyz
First, you'll need to navigate to the webhook section of the Helius Developer Portal, and create a webhook, inputting the account address that you wish to track. In this example (that will be used in the code and for production), we are tracking an address on the Mainnet, with enhanced data unique to Helius. In the Webhook URL section, add the URL of your website - for now, we can add a URL from https://webhook.site/ in order to test. Doing so, we will be able to determine the format of the data sent, and prepare for it’s input into our database.
For this, we will be using Supabase, after creating an account and organisation with all the default settings, you can create a project. The only setting we will be changing is to disable ‘RLS’
This will make it a lot simpler to save data to our database.
Save the Supabase keys to your .env.local
file and we can now establish a connection to our database using the client we installed previously in the package.json
. Create a file called supabaseClient.js
in the outermost directory and input the following:
import { createClient } from '@supabase/supabase-js'
export const supabase = createClient(process.env.supabase_url, process.env.supabase_anon_key)
Depending on how you saved the Supabase keys you may need to change variable names - this is all we need to begin inserting data we receive form the webhook into our database.
To begin adding data to the database, we need to first add the columns that format the data we receive from the webhooks. Helius webhooks allow us to send a test to the webhook, after connecting the previously mentioned webhook as the URL, send a test so that we can see the columns and input them into Supabase.
Pasting this into a code editor like VSC, we can now see the outermost properties of the object we receive from Helius.
Although tedious, this is a necessary step, otherwise an error is thrown by Supabase. Fill these columns in using the test data from above.
Below, are what the columns should look like once you are finished.
Now that we have a place to store the data, we can start receiving it.
In an empty folder:
npx create-next-app
src
folder, choose a name for the project, I’d call it ‘webhook-display’.cd webhook-display
(Optional, START HERE IF INSTALLING THIS WAY) Install TailwindCSS using this tutorial.
Now, you can start your development server by running the following command:
Install all dependencies, replace your package.json
with the following code and run the command npm install
in the terminal
The other dependencies should be preinstalled.
In order for the webhook to be able to send the data, we will need to deploy the site; all we need is an API endpoint that the webhook can reach. Create a new file in /src/api
named webhook.js