Cardano Alerts watches the chain for addresses, stake keys, native-asset policy IDs and script hashes, and tells you when something happens to them. This post is the engineer's view: which parts the service is made of, how an event travels from a new block to your application, and why we built it this way. If you want to connect right away, Connecting to Cardano Alerts has the code; if you want the security argument in full, read How Cardano Alerts keeps each customer's data separate.
The central decision: one scan, separate storage
The obvious design gives every customer their own watcher process. It is simple to explain, but with a hundred customers it means a hundred processes running overlapping queries against the same chain tables, and the cost grows with every sign-up.
We went the other way. Each network is scanned once, every 30 seconds, and that one scan checks every customer's watch list. Isolation is enforced where the data lands: every match is written into a table that belongs to its owner, and from that point on nothing is shared. Each customer gets their own table, their own topics and their own credentials, but not their own process.
One consequence is that the scan interval is the same on every plan. Plans differ in how many criteria you can watch, which channels you get, how long events are kept and how fast you may call the API, not in how quickly a block is checked.
An event goes through six steps:
- Subscribe. You add criteria on the website. The watch-list API takes your customer_id from your login, never from the request.
- Match. Every 30 seconds the scan agent reads new blocks from its own Cardano db-sync database and checks them against the active watch lists for its network.
- Store. A match is written into your event table once the block has your chosen number of confirmations.
- Push. The delivery worker picks up new events and publishes them to your MQTT or Kafka topic.
- Pull. The REST API serves the same table, page by page, at any time.
- Heartbeat. Every 10 minutes each push channel also gets a heartbeat with the last event id, so silence can be told apart from a broken link.
The parts
Watch-list API and UI
Customers manage their criteria themselves on blockchain-applied.com. The page embeds a small Svelte web component that talks to a Rust API. The API identifies you through your website login, maps it to your customer_id in our CRM, and filters every read and write by that id: asking for someone else's criterion returns 404. Criteria are paused, never deleted, and plan limits are checked inside a per-customer lock, so two browser tabs can't race past them.
Scan agent
The scan agent is written in Rust and reads a Cardano db-sync database. Mainnet runs on two independent pipelines, each with its own db-sync, scan agent and event store; preprod has its own pipeline. Event ids are computed from the event itself rather than handed out by a counter, so both mainnet pipelines produce identical rows and either one can serve you. The agent recognises funds received and spent on payment addresses, funds received on stake addresses, mints and burns under a policy ID, and script invocations including redeemer and datum. It only uses a block once it is buried deep enough for your min_confirmations.
Event store
Every customer has their own PostgreSQL schema with one events table, in a separate database per network. Each internal service gets only the permissions it needs: the scan agent may insert, the REST API may read and note when an event was first fetched, and the delivery worker may read and update two delivery-bookkeeping columns, nothing else. Customers never receive database credentials. Retention follows your plan: 30, 90 or 365 days.
Delivery worker
The delivery worker is also Rust and runs once per pipeline. Since both mainnet pipelines hold the same events, the workers of a network compete for a Kubernetes Lease, and only the holder delivers. Each cycle it takes up to 200 undelivered events per customer, locks them so a second worker can't grab the same rows, publishes them, and marks them delivered only after the broker has acknowledged: QoS 1 on MQTT, acks=all on Kafka. A failed event is retried up to five times; after that it stays in your table for the REST API. Which channel you use is a per-customer setting.
REST API
The pull endpoint, GET /events?since_id=, is part of the same Rust API platform as our other BCA APIs and shares its token handling, cache and rate limiting. The token's hash tells the API who you are and which plan you're on; the request has no parameter that could name another customer's table.
MQTT broker
MQTT runs on Mosquitto 2.1, built from source with an authentication plugin we wrote for it. We started the plugin in Rust, but the binding generator couldn't handle current Mosquitto headers, so it is a small C module that implements two checks. On connect it verifies that your access token, which you send as the MQTT username, is valid. On every subscribe it looks up which customer the token belongs to and allows only topics under bca/<customer_id>/, read only. If the lookup fails, the answer is no.
Kafka
Kafka runs on Apache Kafka 4.3 in KRaft mode: two brokers and a third controller, one on each of three nodes, with every topic replicated to both brokers. Each Kafka customer has one topic with one partition, so events stay in order, retained for 7 or 30 days. Clients log in with SCRAM-SHA-512, and each customer's user may read its own topic and use consumer groups that start with its customer_id, nothing more. Until November 2026 this layer ran on Redpanda; we moved to Apache Kafka to stay on an open-source licence, and because clients only speak the Kafka protocol, nothing changed for them.
Ingress and the control plane
All public connections enter through Traefik. For MQTT and Kafka it routes by host name without decrypting, so TLS ends inside the broker that makes the access decision; certificates come from Let's Encrypt. The watch lists, the mapping from tokens to customers, account status and channel settings live in a highly available PostgreSQL cluster. Every 15 minutes an account job copies the list of active subscriptions from our CRM, and a customer without an active subscription simply isn't scanned.
How a client connects
MQTT and the REST API share one credential, your access token. The broker checks it once when you connect, and checks which topics you may read every time you subscribe:
Kafka has its own login, because Kafka clients authenticate with SCRAM rather than a bearer token. We create the topic, the user and two read permissions when you choose Kafka; after that the broker enforces everything on its own:
Ready-to-run commands and client code for all three channels are in Connecting to Cardano Alerts, and our open-source bca-alert-client follows an MQTT or Kafka stream from a single docker run.
Built to keep going
Alerts are only useful if they keep arriving. These are the choices that keep them flowing:
- Two mainnet pipelines. Either one can scan and deliver; the other takes over the lease when the leader stops renewing it.
- Deterministic event ids. Both pipelines write the same rows, so a takeover doesn't renumber anything.
- At-least-once delivery. An event is marked delivered only after the broker acknowledges it. A takeover can resend recent events, which is why consumers de-duplicate on
id. - Pull as the safety net. Whatever happens to a push, the event stays in your table, and
since_idlets you resume exactly where you stopped. - Heartbeats. Every 10 minutes, on every push channel, so monitoring can alert on silence.
- Fail closed. If an identity check can't complete, access is refused rather than granted.
We also check the delivery pipeline with a formal model in TLA+. It found the conditions under which a lease takeover could deliver twice, and it checks that no event can reach another customer's reader. The details are in the isolation post.
The stack at a glance
| Part | Built with |
|---|---|
| Scan agent, delivery worker, REST API, watch-list API | Rust |
| Watch-list UI | Svelte web component on the Ghost site |
| Chain data | Cardano db-sync on PostgreSQL |
| Event store and control plane | PostgreSQL, highly available cluster for the control plane |
| MQTT | Mosquitto 2.1 with our own C authentication plugin |
| Kafka | Apache Kafka 4.3, KRaft, SCRAM-SHA-512 |
| Token cache | Redis |
| Runtime and ingress | Kubernetes (k3s), Traefik, Let's Encrypt via cert-manager |
What's next
- planned Webhooks, signed with a per-customer secret.
- planned WebSocket or Server-Sent Events, for dashboards and browser apps.
- planned The preview testnet, next to mainnet and preprod.
- planned A clustered MQTT broker, so MQTT can spread across nodes the way Kafka already does.
- planned Enterprise options: several push channels at once and dedicated endpoints.