Build Real-Time Event-Driven Apps with FluxRail: Step-by-Step

Learn how to build real-time, event-driven blockchain applications with FluxRail: register signed webhooks, create address subscriptions, verify HMAC signatures, and route events into gas-free transfers, swaps, and fiat payouts — all through one REST API.

Why Event-Driven Architecture Needs a Reliable Source of Truth

Most blockchain integrations start the same way: a cron job that polls a node every few seconds, compares block heights, and hopes nothing was missed between runs. It works until it doesn't — reorgs, dropped RPC calls, rate limits, and the gap between "I saw the transaction" and "I can act on it" all compound. Event-driven applications flip that model. Instead of asking the chain what happened, you subscribe to what matters and let signed webhooks tell you the moment it happens.

FluxRail's Core product is built for exactly this. You register a webhook endpoint, create subscriptions for addresses or contracts across 36+ chains, and FluxRail delivers HMAC-signed events to your server in real time. From there you can trigger downstream actions — a gas-free transfer via Pay, an asset conversion via Liquidity, or a fiat payout via Payouts — all through the same API key and the same base URL.

This guide walks through the whole loop: register a webhook, subscribe to an address, verify the signature, handle the event, and wire it into a real workflow. Every example is copy-pasteable curl or plain HTTP.

Step 1 — Get Your API Key and Pick a Mode

All requests go to https://api.fluxrail.io with an X-API-Key header. Production keys start with flux_live_; sandbox keys start with flux_test_. The sandbox is fully simulated — full lifecycle and webhooks, no real money, no external partner calls.

export FLUX_API_KEY="flux_test_xxxxxxxxxxxxxxxx"
export FLUX_BASE="https://api.fluxrail.io"

Keep the key server-side. It is a bearer credential for your entire account.

Step 2 — Register a Webhook Endpoint

Before anything else, FluxRail needs a destination for events. Create one webhook per environment; you can register multiple if you fan out to different services.

curl -X POST "$FLUX_BASE/api/v1/webhooks" \
  -H "X-API-Key: $FLUX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://api.yourapp.com/hooks/fluxrail",
    "description": "Production event receiver"
  }'

The response includes the webhook id and the signing secret. Store the secret in your secret manager — you will use it to verify every delivery. You can inspect and manage webhooks later:

  • GET /api/v1/webhooks — list all webhooks
  • POST /api/v1/webhooks/{id}/test — fire a test delivery
  • POST /api/v1/webhooks/{id}/toggle — enable or disable
  • GET /api/v1/webhooks/{id}/deliveries — audit recent attempts

An active webhook is a hard prerequisite for several products. /api/v1/transfer and /api/v1/payouts/customers/{id}/send both return 400 if no active webhook exists, because those flows report outcomes only through webhooks.

Step 3 — Create a Subscription

A subscription tells FluxRail which addresses or contracts on which chains you care about. You can subscribe to a single address, a contract (to catch its events), or bulk-create many at once.

curl -X POST "$FLUX_BASE/api/v1/subscriptions" \
  -H "X-API-Key: $FLUX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chain": "ethereum",
    "address": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
    "label": "Treasury hot wallet"
  }'

For bulk onboarding — a marketplace with thousands of seller deposit addresses, for example — use the bulk endpoint:

curl -X POST "$FLUX_BASE/api/v1/subscriptions/bulk" \
  -H "X-API-Key: $FLUX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "subscriptions": [
      { "chain": "polygon", "address": "0xabc...", "label": "seller-101" },
      { "chain": "base",    "address": "0xdef...", "label": "seller-102" }
    ]
  }'

Useful management endpoints:

  • GET /api/v1/subscriptions/stats — counts and summary
  • POST /api/v1/subscriptions/{id}/duplicate — clone a subscription
  • GET /api/v1/subscriptions/{id}/webhook-logs — per-subscription delivery history
  • GET /api/v1/chains — list supported chains and their slugs

Step 4 — Verify the Signature on Every Delivery

Every webhook carries an X-FluxRail-Signature header computed as HMAC SHA-256 over the raw request body using your signing secret. Verify it before parsing JSON, and compare in constant time. Here is a minimal Node.js receiver using the built-in crypto module and Express:

const express = require('express');
const crypto = require('crypto');

const app = express();
const SECRET = process.env.FLUX_WEBHOOK_SECRET;

// Capture the raw body — signatures are computed over the exact bytes.
app.post('/hooks/fluxrail', express.raw({ type: '*/*' }), (req, res) => {
  const signature = req.header('X-FluxRail-Signature');
  const expected = crypto
    .createHmac('sha256', SECRET)
    .update(req.body)
    .digest('hex');

  const valid = signature.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));

  if (!valid) return res.status(401).send('bad signature');

  const event = JSON.parse(req.body.toString('utf8'));
  console.log('event', event.type, 'livemode', event.livemode);

  // Acknowledge fast; do the work asynchronously.
  res.status(200).json({ received: true });
  handleEvent(event).catch(console.error);
});

async function handleEvent(event) {
  // route by event.type — see Step 5
}

app.listen(3000);

The same logic in Python with hmac and hashlib:

import hmac, hashlib, json

def verify(raw_body: bytes, signature: str, secret: str) -> bool:
    expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature)

# in your handler:
# ok = verify(request.data, request.headers['X-FluxRail-Signature'], SECRET)

Two rules keep this robust: always respond 2xx quickly (do the work after acknowledging), and treat delivery as at-least-once — dedupe on event id and make handlers idempotent. The payload also carries livemode, so you can reject sandbox events in production.

Step 5 — Route Events to Downstream Actions

Once a deposit lands on a subscribed address, you have a decision to make. That is where the rest of FluxRail comes in — same API key, same base URL.

Trigger a gas-free transfer (Pay)

Gas is always sponsored by FluxRail, so you never check for it. What isn't sponsored is the value itself — check the balance first, then send.

curl "$FLUX_BASE/api/v1/transfer/balance?chain=ethereum&address=0x742d...&token=USDT" \
  -H "X-API-Key: $FLUX_API_KEY"

curl -X POST "$FLUX_BASE/api/v1/transfer" \
  -H "X-API-Key: $FLUX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chain": "ethereum",
    "to": "0x9f8...",
    "amount": "25.00",
    "token": "USDT",
    "from_private_key": "0x...",
    "client_reference_id": "order-4471"
  }'

The transfer's outcome (transfer.completed, transfer.partial, transfer.failed) arrives on your registered webhook. You can also look up status by FluxRail UUID or your own client_reference_id via GET /api/v1/transfer/{id}.

Convert the asset (Liquidity)

curl -X POST "$FLUX_BASE/api/v1/liquidity/quote" \
  -H "X-API-Key: $FLUX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "from": "USDT", "to": "USDC", "amount": "500.00" }'

A firm quote returns a quote_id; execute it with POST /api/v1/liquidity/execute/{quote_id} and track it under GET /api/v1/liquidity/swaps.

Settle to a bank account (Payouts)

If the event means "pay this merchant in fiat," create the customer once, then send. The rail is chosen from dest_currency and an optional method — FluxRail abstracts the settlement network entirely.

curl -X POST "$FLUX_BASE/api/v1/payouts/customers/user-101/send" \
  -H "X-API-Key: $FLUX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": "250",
    "dest_currency": "USD",
    "method": "ach",
    "destination": {
      "account_owner_name": "Jane Doe",
      "account_number": "000123456789",
      "routing_number": "110000000",
      "account_type": "checking"
    }
  }'

Omit token and network — FluxRail spends straight from the wallet's available balance, auto-picking the stablecoin and chain that covers the amount. The send returns 202 with status: "pending_approval"; every transition after that (payout.pending_approval, payout.processing, payout.completed, payout.failed, payout.returned) fires a webhook. Polling is not a substitute.

Step 6 — Observe and Recover

Event-driven systems fail in specific ways, so build the recovery paths up front:

  • Replay missed events. GET /api/v1/events lists recent events; POST /api/v1/events/{id}/retry re-delivers one. GET /api/v1/events/stats gives volume at a glance.
  • Audit deliveries. GET /api/v1/webhooks/{id}/deliveries shows what was attempted and what your server returned.
  • Test before you ship. POST /api/v1/webhooks/{id}/test fires a real signed delivery to your endpoint.
  • Pause noisy subscriptions. POST /api/v1/subscriptions/{id}/toggle without deleting anything.

A simple operational rule: alert if your webhook endpoint returns non-2xx more than a handful of times in a minute, and reconcile daily by pulling GET /api/v1/events for the last 24 hours against what your handler recorded. That catches the rare delivery that exhausted retries.

Putting It Together

The full loop is short: register a webhook, create subscriptions, verify signatures, route events to Pay, Liquidity, or Payouts, and keep the replay and audit endpoints in your toolbelt. You never poll a node, never manage an RPC provider, and never expose the underlying settlement or verification partners — FluxRail is the connector, and your application only ever talks to one API.

Start in sandbox with a flux_test_ key: create a webhook, subscribe to an address, fire POST /api/v1/webhooks/{id}/test, and watch your handler verify a real signature before you touch production. Full endpoint reference lives at fluxrail.io/docs, and an LLM-friendly map is at fluxrail.io/llms.txt.