LogoLogo
$THX tokenDiscord Community
  • THX Network
  • 🏗️Campaign Managers
    • Getting Started
    • Analytics
    • Quests
      • Daily Quests
      • Invite Quests
      • Twitter Quests
      • Discord Quests
      • Custom Quests
      • Web3 Quests
      • Webhook Quests
      • Steam Quests
      • Quest Locks
    • Rewards
      • Coin Rewards
      • NFT Rewards
      • Custom Rewards
      • Coupon Rewards
      • Discord Role Rewards
    • Participants
    • Integrations
      • Discord
      • Twitter, now X
      • Gitcoin Passport
    • Coins
    • NFT
  • 🧑‍🤝‍🧑USERS
    • Memberships (Free)
    • Lottery (Free)
  • 💡FAQ
    • Pricing
    • Multi Wallet Account
    • Points
    • Other
  • 💻Developers
    • HTML Widget
    • JS SDK
      • Identity
      • Events
    • API
      • API Specification
      • Example
    • Webhooks
    • QR codes
    • Audits
  • 🪙Tokenomics
    • $THX
    • Locking $THX to $veTHX
    • Increasing Locked $veTHX
    • Protocol
    • Token Distribution
  • 🤝ABOUT
    • Team
    • One Pager
    • Community
Powered by GitBook
On this page

Was this helpful?

  1. Developers

Webhooks

Implement a public endpoint in your app and receive campaign events. Verify requests using the signing secret as in the given example. This is what protects the endpoint!

Last updated 10 months ago

Was this helpful?

You can register your webhooks and view the requests we made to them in Developer -> Webhooks.

Webhook are great tools for setting up integrantions with your app using webhook quests and custom rewards.

Example Webhook

This is an example implementation of a webhook for a NodeJS express server.


// Helper method to verify payload signature
function constructEvent(payload, signature, secret) {
	const hmac = crypto.createHmac('sha256', secret);
	hmac.update(payload);
    const calculatedSignature = hmac.digest('base64');
	if (signature !== calculatedSignature) throw new Error('Failed signature verification')
    return JSON.parse(payload);
}

// Sample endpoint controller (Express)
app.post('${path}', (req, res) => {
    let event;

    try {
        // Veries and parses the payload using the WEBHOOK_SIGNING_SECRET which you can get in Developer -> Webhooks
        event = constructEvent(req.body.payload, req.body.signature, WEBHOOK_SIGNING_SECRET);
    } catch (error) {
        return res.status(400).send("Webhook Error: " + err.message);
    }

    switch(event.type) {
        case 'reward_custom.paid': {
            // Handle the event
            // ...
            break
        }
        default : {
            console.log("Unhandled event type " + event.type)
        }
    }

    res.send();
});`;
💻
Custom Rewards
Webhook Quests
Example of a registered webhook for a Custom Reward