Building Real-Time Updates for Your Solana dApp: A Step-by-Step Guide to Implementing a Live Activity Feed

Callbacks play a vital role in various applications in Solana’s ecosystem. Solana is a high-performance blockchain that is designed to scale and handle thousands of transactions per second (TPS) while maintaining a low transaction cost. In this article, we will explore one of the most common use cases of callbacks on Solana — an activity feed.
Callback APIs are a special type of API that can send data automatically when a notable event occurs, unlike regular APIs, which require a request from the client to receive data. This makes them invaluable in a Web 3.0 context, where they can constantly monitor blockchain events and promptly send data to a specific callback URI whenever any event of interest occurs. As a result, clients no longer need to repeatedly check for new data.
One of the major advantages of using callbacks is that developers can write asynchronous code, allowing them to execute code while waiting for a response. This is particularly beneficial for applications that require multiple network requests, such as blockchain transactions.
Some applications on Callback APIs on Solana can be the following:
- Decentralized Finance (DeFi)
Callbacks are commonly used in DeFi protocols to track the status of transactions on Solana. - Gaming
Solana blockchain is a perfect platform for gaming applications due to its high throughput and low latency. Callbacks are used in gaming applications to track the status of in-game events and notify users once specific events have occurred. - Web3 Marketplaces
There are a lot of events happening on Decentralized marketplaces, such as OpenSea or MagicEden. Callbacks can be used to track events on such platforms. - NFTs portfolio and activity feed
Portfolio and analytics-based dApps use callbacks to monitor and display the activities of users like celebrities, internet personalities, or businessmen. With Callback APIs, it’s possible to create custom feeds for small groups like friends, family, or NFT communities.
SHYFT’s Callback API is designed to be easy to use and highly flexible, allowing developers to customize the callback function based on their specific needs. In this article, let us explore how we can create a Live activity feed on Solana using SHYFT APIs.
Read SHYFT API Documentation here.
Callbacks use case — An activity feed
An activity feed is a crucial feature in modern applications that lists real-time events or actions within a website, platform, or environment. On Solana, activity feeds are essential for NFT marketplaces, portfolio-based dApps, and NFT launchpad services, among others. They enable the tracking of updates and information for new listings, sales, and minting. Custom feeds can be created for specific groups, such as communities or close friends, using Callback APIs.
Consider the following scenario, where we will have to create an activity feed for tracking one (or two) accounts( Say 7xhjb.....1hb3 and 8sy.....ghsvs), and keep track of all the NFT mints and Token burn events for these accounts on Solana. Let’s explore how we can create an activity feed for these addresses for custom events on Solana using SHYFT APIs.
Before getting started
To get started, we will need a few things.
Register your SHYFT account and get your own Shyft API key
x-api-key is an authentication parameter, which gives you access to SHYFT APIs. You can get your own API Key from the SHYFT website. Just signup with your email id here and you can get it for free. If you already have an SHYFT API Key, please skip this step.
Node.js or any server environment that supports API calls
We have used Node.js for this article, but these can be bootstrapped using any server environment that supports API calls, or even with frontend React, Next.js or Vanilla JS Applications.
Registering a new callback on Solana
For this scenario, let’s register a new callback for the above addresses, which will track the NFT minting (NFT_MINT) and Token Burn (TOKEN_BURN) events. The API endpoint for registering a new callback on Solana.
POST <https://api.shyft.to/sol/v1/callback/create>
All SHYFT APIs accept x-api-key in their header, which is an authorization parameter used by SHYFT. You can get your own x-api-key here for free. The Content-Type for this API call is **application/json**.
Parameters required for this API call
network: Selects the Solana network cluster, which can be eitherdevnet,testnetormainnet-beta.addresses: This accepts a list of addresses, whose activity (parsed transactions) we are attempting to fetch. In our case, this will be the addresses for which we are creating an activity feed (7xhjb.....1hb3and8sy.....ghsvsas mentioned above)callback_url: URL to which the activity details (transactions) will be sent to. This can be typically a webbook, or a path to a server function, which will be listening for any new data received. (Wondering how to setup one? Click here for steps)events(optional): Accepts a list of events to be notified about. This is an optional parameter that allows the creator to specify which events to be notified about along, thus allowing creators to add filters. In our case, this will be [**NFT_MINT**,**TOKEN_BURN**] as we are only interested in tracking these events.enable_raw(optional): If set to true, raw Solana transactions are also retuned along with the parsed ones.
Setting up a callback receiver with the link specified in the callback_url is also required. (Click here for steps)
Once done, the callback will be registered and the callback_url specified will start receiving parsed transactions related to the addresses 7xhjb.....1hb3 and 8sy.....ghsvs. SHYFT APIs return parsed transactions for all Solana events. NFT_MINT and TOKEN_BURN transactions are returned. Please note that the callback returns an id which is required when updating and stopping this callback.
{
"success": true,
"message": "Callbacks started for the given address",
"result": {
"id": "6438d74d5ef8acebadebf62e",
"network": "mainnet-beta",
"addresses": [
"mv3ekLzLbnVPNxjSKvqBpU3ZeZXPQdEC3bp5MDEBG68",
"TLPv2tuSVvn3fSk8RgW3yPddkp5oFivzZV3rA9hQxtX"
],
"callback_url": "<https://api.my-sample-server.xyz/watch-shyft>",
"events": [
"NFT_MINT"
]
}
}
Note: Callbacks can also be registered using our all new JS SDK for Solana. Feel free to checkout SHYFT’s all new JS SDK here. The request parameters and responses are very similar to what is illustrated above.
const {ShyftSdk,Network} = require("@shyft-to/js");
async function createCallback()
{
const shyft = new ShyftSdk({apiKey:YOUR_SHYFT_API_KEY,network:Network.Mainnet});
const newCallback = shyft.callback.register({
addresses: [
'hRrZGw7NYbwMfL4a25KW2twHzRsAaiLeEx4zYNV35CV2',
'wMfL4a25KW2twHzRhRrZGw7NYbsPHxyeEx4zYNV35XYz',
'LXqL4a25YbsPHxyeEaswP5x4zYNVHzRhRrZGw7KW2twN'
//array of addresses from which the transactions will be fetched
],
callbackUrl: 'https://your-callback-url.com',
//add the url to which the transactions will be sent to
events: [
'TOKEN_BURN',
'NFT_MINT',
'NFT_SALE'
] //Events related to which transactions will be sent
})
}
So that’s pretty much everything about registering a callback to be used in an activity feed. Please note that callbacks created using SHYFT APIs return human-readable parsed transactions. Click here to find out more about the structure of transactions returned.
In the next part of this article, we will explore a little more about managing callbacks on Solana. Stay Tuned!
Up Next: Managing callbacks in an activity feed.
Resources
SHYFT API Documentation
Shyft Website
Get API Key
GitHub
Join our Discord
Javascript SDK
Try out our APIs on Swagger UI

