---
id: BI0002
title: "Live mini explorer"
url: https://carbium.sh/library/blockchainideas/live-mini-explorer
collection: Blockchain ideas
category: Dashboards and explorers
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Live mini explorer

Carbium's hosted WebSocket carries the standard Solana subscriptions, so a live explorer is a page you build on them. Follow one address with a slot ticker, a live feed and a balance, starting from a runnable main.ts.

## Who uses it

A hackathon team needs a demo that shows the chain moving and can be built in a day. A live explorer fits: a ticking slot number, a feed of transactions for one address, and that address's balance. Judges see it working within seconds.

A project team can embed the same panel to show activity on its program address or treasury wallet. A support desk can paste a customer's address and watch the next transaction land while the customer retries.

Teams often ask which explorer API pushes updates. Carbium runs no explorer site and no explorer API. It serves the node's JSON-RPC and [WebSocket subscriptions](https://carbium.sh/docs#websocket) at `services.carbium.sh` under one key, and the explorer is the thin page on top.

## What it shows

Five panels, each fed by one call. Two arrive by push and three by request. main.ts prints the first four panels, and you add the Detail panel on top of it.

| Panel | Call | What the reader sees |
|---|---|---|
| Head slot | `slotSubscribe`, pushed | a slot number that advances about every 200 ms |
| Live feed | `logsSubscribe` with `mentions`, pushed | one row for each transaction that mentions the address: signature and ok or failed |
| Balance | `getBalance`, requested after the feed moves | the SOL balance, refreshed at most every 5 seconds |
| History | `getSignaturesForAddress`, requested on open | the latest page of signatures with slot and status |
| Detail | `getTransaction`, requested on click | fee payer, logs and compute units for one signature |

The feed and the balance travel together on purpose. `accountSubscribe` pushes state for streamed accounts, and a plain SOL wallet is not one of them, so it stays silent there. So `logsSubscribe` with a mention says that something happened, and `getBalance` says what the balance is now.

The feed subscribes at `confirmed`, and the balance and history calls pass `confirmed` as well.

## The build

The script is the server half of the explorer: one file that needs `@solana/kit` and what Node 24 ships. It only reads, with no private key and nothing sent.

1. Take the address from the command line and the key from `CARBIUM_KEY`. Build one RPC client with the key and keep it for the life of the process.
2. At start, fetch the last 5 signatures with `getSignaturesForAddress` and the balance with `getBalance`, both at `confirmed`.
3. Open one WebSocket to `wss://services.carbium.sh` with the key as `?api-key=`. The key may also ride as the subprotocol `api-key.<YOUR_KEY>`, which keeps it out of URL logs.
4. Send `slotSubscribe` and `logsSubscribe` with `{ mentions: [address] }`. Each reply holds a subscription id or an error, and a subscription the server refuses costs nothing.
5. On each `logsNotification`, add one to the count, store the signature with ok or failed taken from `err`, and flag the balance as stale.
6. Once a second, repaint the slot, the count, the newest row and the KiB received so far. Every 5 seconds, if the balance is flagged stale, read it a single time.

`main.ts` (run: `CARBIUM_KEY=<YOUR_KEY> node main.ts <ADDRESS>`)

```ts
// BI0002 · Live mini explorer
// https://carbium.sh/library/blockchainideas/live-mini-explorer
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { address, createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";

const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY to your Carbium API key.");
  process.exit(1);
}
// Any address works. The default is the Token program, busy enough to show a feed within seconds.
const WATCH = process.argv[2] ?? "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
const target = address(WATCH);
const WS_URL = `${process.env.CARBIUM_WS_URL ?? "wss://services.carbium.sh"}/?api-key=${key}`;
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);

let stale = false; // true when the feed moved since the last balance read
let lastLine = 0;
let seen = 0;
let latest = "none yet";
let bytes = 0;

const warn = (what: string) => (e: unknown) => console.error(`${what} failed:`, e instanceof Error ? e.message : e);

async function balance(): Promise<void> {
  const { value } = await rpc.getBalance(target, { commitment: "confirmed" }).send();
  console.log(`balance ${Number(value) / 1e9} SOL`);
}

async function history(): Promise<void> {
  const rows = await rpc.getSignaturesForAddress(target, { limit: 5, commitment: "confirmed" }).send();
  for (const r of rows) console.log(`history ${r.signature.slice(0, 12)} slot ${r.slot} ${r.err ? "failed" : "ok"}`);
}

function connect(): void {
  const ws = new WebSocket(WS_URL);
  const call = (id: number, method: string, params?: unknown[]) =>
    ws.send(JSON.stringify({ jsonrpc: "2.0", id, method, params }));
  ws.onopen = () => {
    call(1, "slotSubscribe");
    call(2, "logsSubscribe", [{ mentions: [WATCH] }, { commitment: "confirmed" }]);
  };
  ws.onmessage = (ev) => {
    const text = String(ev.data);
    bytes += Buffer.byteLength(text);
    const msg = JSON.parse(text);
    if (msg.id) {
      console.log(msg.error ? `subscription ${msg.id} refused: ${msg.error.message}` : `subscription ${msg.id} open`);
    } else if (msg.method === "logsNotification") {
      const { signature, err } = msg.params.result.value;
      seen += 1;
      stale = true;
      latest = `${signature.slice(0, 12)} ${err ? "failed" : "ok"}`;
    } else if (msg.method === "slotNotification" && Date.now() - lastLine >= 1000) {
      lastLine = Date.now();
      console.log(`slot ${msg.params.result.slot} | ${seen} tx seen | latest ${latest} | ${(bytes / 1024).toFixed(1)} KiB received`);
    }
  };
  ws.onclose = () => setTimeout(connect, 2000);
  ws.onerror = () => ws.close();
}

setInterval(() => {
  if (!stale) return;
  stale = false;
  balance().catch(warn("balance"));
}, 5000);

history().catch(warn("history"));
balance().catch(warn("balance"));
connect();
```

The slot stream pushes about five notifications a second, more than a reader can follow, so the repaint gate does the throttling. The close handler waits 2 seconds, reconnects and subscribes again. To bring this into a browser, keep the script as a small server and forward its events to pages over server-sent events. One upstream socket then feeds any number of viewers, and the key stays out of page script, where every visitor could read it.

## What it costs

Opening the slot subscription costs 5 credits and opening the logs-mentions subscription costs 25. After that each bills 20 credits per MiB sent. `getSignaturesForAddress` takes 50 cells per call, so call it once on open and on demand, never on a timer.

Assume 100 bytes per slot notification at about five a second, and 2 KiB per log notification at 10 mentions a second. Swap in your own once you see the KiB the script prints. Those figures give about 1.7 MiB and 70 MiB an hour, which is about 1,470 credits an hour with both opening fees.

| Plan | Credits | getSignaturesForAddress rate | One hour of the feed |
|---|---|---|---|
| Free ($0) | 500K once, at sign-up | 0.24 req/s | about 0.3% of the grant |
| Dev ($20) | 10M per month | 1.2 req/s | about 0.015% of the month |
| Business ($250) | 50M per month | 100 req/s | about 0.003% of the month |
| Pro ($500) | 200M per month | 500 req/s | about 0.0007% of the month |

The size of the mentions feed follows the traffic of the address you choose: twenty times the traffic means twenty times the megabytes. A wallet or a single program's own account is gentle. A core program such as the token program floods the socket, which is why it is the script's default and a first run shows movement within seconds. Stop that run after a minute.

[Limits](https://carbium.sh/docs#limits) belong to the account, so other tools on the same keys draw on the same budget. Free carries 5 sockets and the explorer server holds one. A page that calls `getTransaction` on each click pays 50 cells a call, which on Free at 0.24 req/s works out to about one detail view every 5 seconds.

## What to add next

- A detail panel: call `getTransaction` when a row is clicked and cache the answer by signature, since a landed transaction never changes.
- A pending box: `signatureSubscribe` on a pasted signature sends a single confirmation and then ends, which suits a page that waits on one transaction.
- Several addresses: open one `logsSubscribe` for each address and de-duplicate by signature, because a transaction that mentions two watched addresses arrives twice.
- Program-owned accounts: use `accountSubscribe` for state that changes in place, such as a pool or a config account.
- A token view: [SPL token balance](https://carbium.sh/library/howsolana/spl-token-balance) covers the token side of a balance panel, and the same logs feed drives the error tally in [Failed-mint monitor](https://carbium.sh/library/blockchainideas/failed-mint-monitor).

## Where it ends

- Carbium serves chain data and nothing layered over it. The node supplies no address labels, token names, images or transaction graphs, so the page shows signatures and statuses as reported.
- History reaches back through the 30-day address index at most. An empty page beyond that marks the index's age limit and says nothing about when the address first transacted.
- The feed shows transactions that landed. A transaction rejected at preflight, or one whose blockhash expired, never produces logs.
- The balance is polled every 5 seconds after activity, so it can trail the feed by that long.
- A network-wide feed needs all logs, which opens at 200 credits and delivers every transaction on the chain. One address costs a small fraction of that to carry.
- A block view on a blocks subscription also opens at 200 credits.
- A holders panel built on `getTokenLargestAccounts` gets -32601 because Carbium does not serve that method, so drop the panel and do not retry the call.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The subscription reply is an error, or the socket closes straight away. | Check CARBIUM_KEY and confirm the account sits under its socket cap (Free carries 5). A refused subscription costs nothing, so the script's reconnect loop on a bad key spends no credits. |
| The slot line moves but the transaction count stays at 0. | The connection works and the address is quiet. Point the script at a busy address, such as the default token program, to watch the feed move. |
| The balance stays put after a row appears. | A transaction that mentions an address need not move its SOL. A failed or token-only transaction leaves the balance as it was. Check the row's status and wait for the next 5 second refresh. |
| History comes back empty for an old address. | The address index keeps up to 30 days, so label an empty history as no transactions in the last 30 days, whatever the address's age. |
| A call answers 429. | Try once more after the retry-after hint. If it repeats, slow the refresh to your plan's rate and look at what else on the account is calling, since the limit is shared across its keys. |
| Credits fall faster than the table above. | Read the KiB figure on the repaint line. A busy address streams every transaction that mentions it, so pick a narrower address, or widen the repaint gap on a page that needs fewer rows. |

## Questions

### Which WebSocket methods does a live explorer need?

Three cover most of it: `slotSubscribe` for the head, `logsSubscribe` with a mention for an address's activity, and `signatureSubscribe` for one pending transaction. Add `accountSubscribe` for streamed accounts.

### Can the browser open the WebSocket itself?

It can, but the key then rides in the URL or the subprotocol where every visitor can read it. Keep the socket on a small server and push events out to pages.

### Why not accountSubscribe for a wallet balance?

A plain SOL wallet is not a streamed account, so it stays silent on it. The supported route is a logs mention to learn that something happened and `getBalance` to read the result.

### Will this run on the Free plan?

Yes. At the assumed sizes the feed uses about 1,470 credits an hour, so the 500K credits cover several hundred hours of the stream alone. The history call runs once at start, well under 0.24 req/s.

## Related

- [SPL token balance](https://carbium.sh/library/howsolana/spl-token-balance) (How to use Solana, HS0001)
- [Failed-mint monitor](https://carbium.sh/library/blockchainideas/failed-mint-monitor) (Blockchain ideas, BI0001)
- [carbium.sh/docs#websocket](https://carbium.sh/docs#websocket)
- [carbium.sh/docs#limits](https://carbium.sh/docs#limits)
- [carbium.sh/docs#rpc](https://carbium.sh/docs#rpc)
- [carbium.sh/docs#auth](https://carbium.sh/docs#auth)
- [carbium.sh/docs#endpoints](https://carbium.sh/docs#endpoints)
