This guide will walk you through setting up your first event listener with Helius.

Prerequisites

  • A Helius API key (Get one from the Helius Dashboard)
  • A webhook endpoint that can receive POST requests (for webhook listeners)

Setup Options

Helius offers two primary methods for event listening:

  1. Webhooks - Receive notifications when specific blockchain events occur
  2. WebSockets - Real-time event streaming for responsive applications

Quick Setup: Webhooks

1

Create a Webhook

curl -X POST 'https://api.helius.xyz/v0/webhooks' \
  -H 'Content-Type: application/json' \
  -d '{
    "accountAddresses": ["YOUR_ACCOUNT_ADDRESS"],
    "transactionTypes": ["ANY"],
    "webhookURL": "YOUR_WEBHOOK_URL",
    "authHeader": {"key": "value"}, // optional
    "webhookType": "enhanced"
  }' \
  -H 'Authorization: Bearer YOUR_API_KEY'
2

Verify Receipt

Events matching your criteria will be sent to your webhook URL as POST requests. The payload will include:

{
  "accountData": [],
  "description": "",
  "events": {},
  "fee": 5000,
  "feePayer": "YOUR_ACCOUNT_ADDRESS",
  "signature": "TRANSACTION_SIGNATURE",
  "slot": 1234567,
  "timestamp": 1234567890000,
  "type": "TRANSACTION_TYPE"
}

Quick Setup: WebSockets

1

Connect to WebSocket Endpoint

const WebSocket = require('ws');

// Connect to Helius WebSocket endpoint
const ws = new WebSocket('wss://api.helius.xyz/v0/webhook-events?api-key=YOUR_API_KEY');
2

Set Up Event Handlers

// Handle connection open
ws.on('open', () => {
  console.log('Connected to Helius WebSocket');
});

// Handle incoming messages
ws.on('message', (data) => {
  const event = JSON.parse(data);
  console.log('Received event:', event);
});

Next Steps

For additional help, join our Discord or Telegram communities.