API Reference

Webhooks

Receive real-time notifications when events occur on the TokenKickstarter platform. Webhooks push data to your server as soon as events happen.

Why Use Webhooks?

  • Real-time updates instead of polling
  • Reduce API calls and stay within rate limits
  • Build responsive applications

Setup

1

Create Endpoint

Create an HTTPS endpoint on your server to receive webhook payloads

2

Register Webhook

Register your endpoint URL in the developer dashboard

3

Select Events

Choose which events you want to receive notifications for

4

Verify Signatures

Validate webhook signatures to ensure requests are authentic

Available Events

presale.created

A new presale has been created

presaleIdcreatortokenchain
presale.contribution

A contribution was made to a presale

presaleIdcontributoramounttokensAllocated
presale.finalized

A presale has been finalized

presaleIdsuccesstotalRaisedliquidityAdded
token.created

A new token has been deployed

tokenAddressnamesymbolcreatorchain
lock.created

A new liquidity lock has been created

lockIdtokenamountunlockTime

Payload Format

All webhook payloads follow a consistent JSON structure:

{
  "event": "presale.contribution",
  "timestamp": 1704067200,
  "data": {
    "presaleId": "0x1234...5678",
    "contributor": "0xabcd...ef01",
    "amount": "1000000000000000000",
    "tokensAllocated": "5000000000000000000000",
    "transactionHash": "0xdef0...1234"
  },
  "signature": "sha256=abc123..."
}

Signature Verification

Each webhook includes a signature in the X-Webhook-Signature header. Verify this to ensure the request is authentic.

const crypto = require('crypto');

function verifySignature(payload, signature, secret) {
  const expected = 'sha256=' + crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(payload))
    .digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

Best Practices

  • Respond with 200 OK quickly and process asynchronously
  • Implement idempotency to handle duplicate deliveries
  • Always verify webhook signatures before processing
  • Use a queue to handle high volumes of webhooks

Continue Learning

Learn about rate limits to ensure your integration runs smoothly.