services
Get a key

library / Integrations / I0045

Chain halt SMS alerts

A small Node watcher reads the newest Solana slot from Carbium every 2 seconds. When the number stops rising for 10 seconds it posts one SMS to a gateway you name, and it posts a second one when blocks flow again.

By Carbium · Chat and notifications · I0045 · updated 2026-11-22

01

What the watcher watches

A halt, seen from outside, is a slot number that stops moving. The watcher asks Carbium for the newest slot every 2 seconds and remembers when that number last went up. If it has not gone up for 10 seconds, no new block has reached this node in that time, and one SMS goes out. When the slot moves again, a second text says so.

The process is always in one of three states and sends a text only when the state changes.

StateWhenSMS
okThe slot rose within the last 10 seconds.One, when the watcher comes back from another state.
haltedgetSlot answers, and the number has not risen for 10 seconds.One, when it enters this state, with the seconds of silence and the last slot.
unreachablegetSlot has not answered for 10 seconds, through errors or timeouts. The chain state is unknown.One, when it enters this state.

A call that fails or times out does not count as a halt on its own. The two clocks, one for the last answer and one for the last rise, keep a network blip from reading as a stopped chain. A 429 skips that poll and leaves the state where it was.

02

The Solana side: a slot that stops rising

The call is getSlot at processed, set on the call. @solana/kit 8.6.0 would fill in confirmed if the field were left out, and processed is the commitment that shows a new block first. The levels are laid out in Solana commitment levels. Carbium answers at its RPC endpoint, https://services.carbium.sh, and the watcher reads that address from CARBIUM_RPC_URL when you set it.

Since the Alpenglow switch a slot lasts about 200 ms, so 10 quiet seconds is around 50 slots with no new block. A slot whose leader produced nothing does not move the number either, and the next block makes it jump past the gap. A few skipped slots therefore never raise the alert, because the window needs 10 seconds with no block at all.

The window is a tradeoff you set with HALT_SECS. A short value finds a stop sooner and sends more false alarms when the node's own slot stalls for a moment. A long value stays quiet through hiccups and tells you later. The default of 10 seconds is 5 polls of silence.

A slot comparison would look the same if the node itself were stuck, for example during a restart or a stalled catch-up. The text says what this node saw, so a halt message means "no new block here". Confirming a network-wide stop takes a second source that you check by hand.

03

The SMS side: one POST to a gateway

SMS needs a carrier path, and that part stays yours. The watcher sends a JSON POST of the form {"to": "+15550100", "text": "..."} to the URL in SMS_GATEWAY_URL, with SMS_TO as the number. Any HTTP service that takes that body works, whether a small adapter in front of the SMS provider you already pay for or a modem box on your network. If your provider wants a different body, change the one JSON.stringify line.

The text is cut to 160 characters so it stays one SMS segment. It looks like Solana halt? No new block for 12 s, last slot 412345678. Treat the gateway URL as a secret if it carries a credential, and keep it in the environment.

The state variable moves only after the gateway answers with a success status. If the gateway is down or the URL is wrong, the next poll tries again with fresh numbers. With SMS_GATEWAY_URL unset the text prints to the console, which is the quickest way to watch it before any number is wired in.

04

The watcher

Install the one dependency with npm install @solana/[email protected] and set "type": "module" in package.json. Node 24 strips the types on load. CARBIUM_KEY is required, and the file exits with a message when it is missing. SMS_GATEWAY_URL, SMS_TO, HALT_SECS and CARBIUM_RPC_URL are optional.

main.ts
// I0045 · Chain halt SMS alerts// https://carbium.sh/library/integrate/chain-halt-sms-alerts// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport {  createDefaultRpcTransport,  createSolanaRpcFromTransport,  isSolanaError,  SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR,} from "@solana/kit";const key = process.env.CARBIUM_KEY;if (!key) { console.error("Set CARBIUM_KEY."); process.exit(1); }const gateway = process.env.SMS_GATEWAY_URL; // unset: alerts print instead of sendingconst to = process.env.SMS_TO ?? "";const haltMs = Number(process.env.HALT_SECS ?? 10) * 1000;if (!(haltMs > 0)) { console.error("HALT_SECS must be a number above 0."); process.exit(1); }const POLL_MS = 2_000;const rpc = createSolanaRpcFromTransport(  createDefaultRpcTransport({    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",    headers: { "x-api-key": key },  }),);type State = "ok" | "halted" | "unreachable";let state: State = "ok";let slot = -1n;let movedAt = Date.now(); // last time the slot went uplet answeredAt = Date.now(); // last time getSlot answered// Seconds a 429 asks us to wait, or 0 for any other error.const tooMany = (e: unknown) =>  isSolanaError(e, SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR) && e.context.statusCode === 429    ? Number(e.context.headers.get("retry-after")) || 1    : 0;const why = (e: unknown) =>  isSolanaError(e, SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR) ? `HTTP error (${e.context.statusCode})` : e instanceof Error ? e.message : String(e);async function notify(text: string) {  console.log(text);  if (!gateway) return;  const res = await fetch(gateway, {    method: "POST",    headers: { "content-type": "application/json" },    signal: AbortSignal.timeout(5_000),    body: JSON.stringify({ to, text: text.slice(0, 160) }),  });  if (!res.ok) throw new Error(`SMS gateway answered ${res.status}`);}async function poll(): Promise<number> {  const now = Date.now();  try {    const s = await rpc.getSlot({ commitment: "processed" }).send({ abortSignal: AbortSignal.timeout(5_000) });    answeredAt = now;    if (slot === -1n) console.log(`watching from slot ${s}, alert after ${haltMs / 1000} s without a new one`);    if (s > slot) { slot = s; movedAt = now; }  } catch (e) {    const wait = tooMany(e);    if (wait) {      console.error(`poll skipped: 429 on getSlot, next poll in ${Math.max(POLL_MS / 1000, wait)} s`);      return Math.max(POLL_MS, wait * 1000); // state unchanged    }    console.error("getSlot failed:", why(e));  }  const next: State = now - answeredAt > haltMs ? "unreachable" : now - movedAt > haltMs ? "halted" : "ok";  if (next !== state) {    const quiet = Math.round((now - movedAt) / 1000);    const silent = Math.round((now - answeredAt) / 1000);    await notify({      ok: `Solana blocks are flowing again, slot ${slot}.`,      halted: `Solana halt? No new block for ${quiet} s, last slot ${slot}.`,      unreachable: `Carbium RPC gave no answer for ${silent} s, chain state unknown.`,    }[next]);    state = next; // only after the gateway accepted it, so a failed send is retried  }  return POLL_MS;}for (;;) {  const wait = await poll().catch((err: unknown) => {    console.error("alert failed:", err instanceof Error ? err.message : err);    return POLL_MS;  });  await new Promise((r) => setTimeout(r, wait));}

run: node main.ts

05

Run it and test the alert

Start node main.ts under a supervisor such as a systemd unit so it survives a crash or a reboot. The first poll prints the slot it started from, then the file is quiet until something changes.

To see an alert fire without waiting for a real halt, point the watcher at a closed port: CARBIUM_RPC_URL=http://127.0.0.1:9 HALT_SECS=4 node main.ts. After 4 seconds it enters unreachable and sends that text, which proves the gateway path end to end. Remove the override afterwards. A restart during a halt starts the clock again, so you get a fresh text after HALT_SECS.

06

What it costs against your limits

getSlot is a cached read at 1 cell, and Free allows 5 req/s of that class. One call every 2 seconds is 0.5 req/s and 30 cells a minute, a tenth of Free's rate.

Limits are per account, so every key on it shares one budget.

07

Where it ends

  • It sees one node's view. A stuck node and a stopped chain look the same, so check a second source of your own before you act on a halt text.
  • It catches a full stop only. A chain that produces blocks at half speed keeps the number rising and never alerts.
  • While every poll gets a 429 the state does not change, so a halt during a long run of 429s goes unseen until a poll gets through.
  • A halt text takes HALT_SECS plus up to one poll of 2 seconds, and the carrier adds its own delay on top. An unreachable text can take HALT_SECS plus the 5-second call timeout and the 2-second sleep, because a hanging getSlot holds the loop for up to 5 seconds.
  • The SMS path is yours: the watcher sends one HTTP POST and cannot see whether the phone got the text.
  • A watcher that dies sends nothing. Supervise the process and watch it from another machine.
  • It keeps its state in memory only. A restart begins at ok with no memory of an earlier halt.
08

When it goes wrong

what goes wrongwhat to do
The log shows alert failed: SMS gateway answered 401 and the same alert is retried every 2 seconds.The gateway rejects the request. Check that SMS_GATEWAY_URL holds the whole URL with its credential and that SMS_TO is a number in the format the gateway wants. The next poll sends the current state.
Halt texts arrive for a few seconds at a time and recover on their own.The node's own processed slot stalled briefly, as it can during a catch-up, and HALT_SECS is short enough for that stall to cross it. Raise it to 10 or more so a short stall stays inside the window.
The log shows getSlot failed: HTTP error (401) and an unreachable text follows.CARBIUM_KEY is cut short or wrong, or CARBIUM_RPC_URL points somewhere else. Set the whole key and unset the URL override.
No texts come and the log fills with poll skipped: 429.Your account's rate budget is spent, usually by app traffic on other keys. Lower that traffic or move to a plan with a higher rate. The state stays where it was until a poll gets through.
The terminal shows Set CARBIUM_KEY. and the process exits at once.CARBIUM_KEY is unset. Export it and start again.
09

Questions

Does a skipped slot trigger the alert?

No. A slot with no block moves nothing, and the number jumps over it when the next block lands. The alert needs 10 seconds with no new block, about 50 slots.

Why poll instead of subscribing to slots?

A WebSocket slot subscription opens at 5 credits and costs 20 credits per MiB sent. Polling is simpler to restart, and a stalled socket would itself look like a halt.

Which SMS provider does it need?

None in particular. It posts {to, text} to one URL, so any gateway that accepts that body works, and an adapter takes a few lines when yours wants another shape.

Does it alert when Carbium's node falls behind the network?

No. It only sees whether this node's slot stops rising, so a node that lags but keeps moving never alerts. For slot-lag alerts see Slack slot-lag alerts.