Transaction Callbacks

Get notified about on-chain transactions in real-time, parsed and summarized.

Github repo for a Merkle tree indexer using Transaction Callbacks.

Overview

To create powerful event-driven systems, you need to be able to monitor transactions happening on a blockchain in real-time. You can set up transaction callbacks to watch specific addresses, and whenever a transaction occurs on those addresses, you'll receive a notification to your backend through a POST request. You can also setup filters for different types of transactions you want to be notified about, such as NFT sales, token transfers, NFT burns, and more.

You can view the full list of supported on-chain transaction types here.

The best part is that when you receive these callbacks, they come with structured information about the transaction, including its type and detailed data, so you don't need to make additional requests to the blockchain. This makes it easier to build applications that react to specific blockchain activities.

How to Create Transaction Callbacks

You can create callbacks programmatically through our APIs, Postman or Swagger UI.

const createTransactionCallback = async () => {
    try {
        const response = await fetch(
            "https://api.shyft.to/sol/v1/callback/create",
            {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                    'x-api-key': '{ YOUR-API-KEY }'
                },
                body: JSON.stringify({
                    "network": "mainnet-beta", //or devnet
                    "addresses": [
                        "ARRAY OF ADDRESSES YOU WANT TO RECEIVE CALLBACKS FOR"
                    ],
                    "callback_url": "YOUR SERVER URL",
                    "type": "CALLBACK", //optional, default is CALLBACK
                    "enable_raw": true, //optional, to receive jsonParsed Solana tx
                    "enable_events": true //optional, to receive anchor events emitted in the tx
                }),
            }
        );
        const data = await response.json();
        console.log(data);
    } catch (e) {
        console.error("callback creation error", e);
    }
}
createTransactionCallback();

Transaction Callback Payload

There are 3 major parts in the response structure

  • actions: The most important section. An array containing structured information about the transaction. it contains type, source_protocol and info. The main action summary is present under info and will differ based on the transaction type. You can check various actions and their response structures here.

  • events: It is an array of parsed anchor events containing data and name of events emitted in the transaction. These are automatically parsed if an IDL is provided.

  • raw: This is the standard Solana jsonParsed transaction

{
    "timestamp": "",
    "fee": ,
    "fee_payer": "",
    "signers": [
    ],
    "signatures": [
    ],
    "protocol": {
        "address": "",
        "name": ""
    },
    "type": "",    //Main Transaction type
    "status": "",
    //actions is an array of parsed instructions 
    "actions": [
        {
            "info": {
                //info contains action specific response structure
            },
            "source_protocol": {
                "address":,
                "name":
            },
            "type": "action type"
        }
    ],
    "raw": {
        //jsonParsed Solana transaction
    },
    "events": [
    //Array of anchor events emitted in the transaction
      {
        "data": {
        //Parsed anchor event data if IDL is present
        },
        "name": ""
      }
    ],
    "accounts": [
        {
            "address": ,
            "owner": ,
            "lamports": ,
            "data": ,
        }
    ]
}

You can check out different transactions on Translator and see their response structures and understand better.

Last updated