Webhook

When setting up a project, you can choose between two channels of notifications:

  • email

  • webhook

On this page, we will focus on how to set up a webhook in your application to receive the data from Leandexer.

What is a webhook?

A webhook is a method used to send real-time data from one application to another based on specific events. This is achieved by configuring a URL endpoint in the receiver application, which listens for incoming HTTP requests triggered by the sender application whenever the designated event occurs. Webhooks enable seamless, automated data transfers and integrations without the need for continuous polling or manual updates.

Setting up your webhook

To set up the webhook, simply define a new route on your back-end router, using the following payload as request body:

{
    "smart_contract_address": String,
    "project": {
        "id": BigInteger,
        "name": String
    },
    "time": BigInteger, // epoc time format
    "network": String,
    "event": {
        "name": String,
        "payload": {
          "encoded": String, // hex string encoded payload 
          "decoded": {
              "from": String,
              "to": String,
              "amount": BigInteger
          }
      },
      "block_number": BigInteger
    }
}

A little explanation of the code above:

  • smart_contract_address: the address of the smart contract concerned by the notification

  • project are the information related to the project sending the notification: the name and the identifier

    • id is the internal identifier of the project in the system, that you can use on your application to map data

    • name is the label you attached to your project when creating it in the Leandexer App

  • time is the epoch formated time of the emitted event

  • network is the name of the network on which the event was emitted

  • event is all the data related to the event itself:

    • name the name of the event, as emitted by the smart contract (i.e. Transfer Approval ...)

    • payload is the payload of the event, containing:

      • encoded the hexadecimal encoded string, as read on the blockchain

      • decoded the decoded, humanly readable content of the event:

        • from the wallet which emitted the transaction

        • to if eligible, the wallet receiving the transaction

        • amount if eligible, the amount exchanged during the transaction

    • block_number the number of the block which validated the transaction

Last updated