---
id: I0092
title: "Pusher wallet activity channels"
url: https://carbium.sh/library/integrate/pusher-wallet-activity-channels
collection: Integrations
category: Queues and streams
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Pusher wallet activity channels

A Node relay holds one Carbium log subscription for a wallet and triggers a small Pusher event on a private channel for each transaction that mentions it, so browsers receive the signature, slot and error without opening a Solana socket.

## What can push

Neither library pushes anything to a page. `spl-token` builds instructions and reads token accounts, and it opens no subscription. `@solana/web3.js` and `@solana/kit` can open a WebSocket subscription, but the callback fires in the process that opened it. A browser tab that does this carries your API key and holds a socket of its own. Pusher takes over the fan-out: your server keeps the one Solana subscription, and browsers hold only a Pusher connection.

For a wallet, the Solana side is `logsSubscribe` with a `mentions` filter. A plain SOL wallet stays silent on [accountSubscribe](https://carbium.sh/docs/websocket), so the signal is a log mention, followed by a `getBalance` read when you want the number. A mention matches any transaction that lists the wallet among its accounts.

| Hop | Between | What moves |
|---|---|---|
| 1 | Carbium to your relay | A `logsNotification` with the signature, the error and the log lines |
| 2 | Relay to Pusher | A signed POST that triggers event `tx` on `private-wallet-<address>` |
| 3 | Pusher to the page | The event body: signature, slot and err |
| 4 | Page to your server | An optional balance read that passes the event's slot |

## Channel names and auth

Name the channel after the wallet: `private-wallet-<address>`. A base58 address is letters and digits, which fits Pusher's channel name rules, and the `private-` prefix makes Pusher ask your server before a browser may subscribe. One channel per wallet keeps a page on the wallets its user may see.

When pusher-js subscribes to a private channel, it posts `socket_id` and `channel_name` to your auth endpoint. The endpoint checks that the signed-in user may watch that wallet, then answers with `{ auth: "<app key>:<signature>" }`. The signature is the HMAC-SHA256 hex digest of `<socket_id>:<channel_name>` under the app secret. The `authorize` function in the file is that computation. Mount it in your web framework; the relay itself never calls it.

> The relay holds the Pusher secret and the Carbium key. The page gets the Pusher app key and nothing else; the app key is meant to be public.

## The event payload

Each event is named `tx` and carries three fields. `signature` is the transaction signature. `slot` is the slot of the notification, kept as text so every client parses it the same way. `err` is `null` for a transaction that succeeded and an object for one that failed. The notification also holds every log line, which can run to kilobytes, so the relay drops them. Pusher caps an event's data at 10 KB by default, and a page needs three fields.

The signature is the handle for everything else. The page can link to an explorer, ask your server for the transaction, or dedupe. A page that reconnects, or the fallback read in the file, can hand it a signature it already has, so the page keeps the signatures it has seen and skips repeats.

## Following up with a balance read

The event says that something touched the wallet and carries no balance. When the page needs the number, it asks your server, and the server calls `getBalance` with `minContextSlot` set to the event's slot. The answer then comes from a node at that slot or later, and a node that is behind answers with an error. Pass `commitment: "confirmed"` on the read, as the file does on the subscription and on its signature lookup. @solana/kit 8.6.0 fills in `confirmed` when a call leaves commitment out, while the JSON-RPC server's own default is `finalized`.

A busy wallet fires many events a second. Let the page wait a few hundred milliseconds after the last event and read once, at the newest slot it was told about. Keep the read on your server, since the key lives there, and put a short cache in front of it. [Every key on an account shares one read rate](https://carbium.sh/docs/limits), and a call over its rate can end in a 429.

## The relay

Install `@solana/kit@8.6.0`, set `"type": "module"` in `package.json` and run on Node 24, which strips the types on load. `CARBIUM_KEY` is your [API key](https://carbium.sh/docs/auth) and the wallet is the first argument. With `PUSHER_APP_ID`, `PUSHER_KEY`, `PUSHER_SECRET` and `PUSHER_CLUSTER` set, each event goes to the Pusher REST API as a signed POST. With them unset, the file only prints, which lets you watch the events before a Pusher app exists.

Each notification prints one line with the channel, the event name and the body. If 15 seconds pass with no notification, the file reads the newest signature with `getSignaturesForAddress` and prints the same body for it, so a quiet wallet still shows you what a page would receive.

`main.ts` (run: `node main.ts`)

```ts
// I0092 · Pusher wallet activity channels
// https://carbium.sh/library/integrate/pusher-wallet-activity-channels
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

import { address, createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";
import { createHash, createHmac } from "node:crypto";

const key = process.env.CARBIUM_KEY;
const wallet = process.argv[2];
if (!key || !wallet) {
  console.error("Set CARBIUM_KEY and pass a wallet: node main.ts <wallet>");
  process.exit(1);
}
const apiKey: string = key;
const channel = `private-wallet-${wallet}`;
const { PUSHER_APP_ID: appId, PUSHER_KEY: pKey, PUSHER_SECRET: secret, PUSHER_CLUSTER: cluster } = process.env;

// What your auth endpoint answers when pusher-js asks to join a private channel.
export const authorize = (socketId: string, name: string) => ({
  auth: `${pKey}:${createHmac("sha256", secret ?? "").update(`${socketId}:${name}`).digest("hex")}`,
});

type Tx = { signature: string; slot: string; err: unknown };
let sent = 0;

async function publish(tx: Tx) {
  sent++;
  console.log(channel, "tx", JSON.stringify(tx));
  if (!appId || !pKey || !secret || !cluster) return; // no Pusher app set: print only
  const body = JSON.stringify({ name: "tx", channels: [channel], data: JSON.stringify(tx) });
  const q = new URLSearchParams({
    auth_key: pKey,
    auth_timestamp: String(Math.floor(Date.now() / 1000)),
    auth_version: "1.0",
    body_md5: createHash("md5").update(body).digest("hex"),
  });
  const path = `/apps/${appId}/events`;
  const sig = createHmac("sha256", secret).update(`POST\n${path}\n${q}`).digest("hex");
  const res = await fetch(`https://api-${cluster}.pusher.com${path}?${q}&auth_signature=${sig}`, {
    method: "POST",
    headers: { "content-type": "application/json" },
    body,
  });
  if (!res.ok) console.error("pusher", res.status, await res.text());
}
const report = (e: unknown) => console.error("relay:", e instanceof Error ? e.message : e);

const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({ url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": apiKey } }),
);

// A quiet wallet still shows the event shape: after 15 s, publish its newest signature.
setTimeout(async () => {
  if (sent) return;
  console.error("no notification in 15 s, using the newest signature");
  try {
    const [newest] = await rpc
      .getSignaturesForAddress(address(wallet), { limit: 1, commitment: "confirmed" })
      .send({ abortSignal: AbortSignal.timeout(5_000) });
    if (newest) await publish({ signature: newest.signature, slot: String(newest.slot), err: newest.err });
  } catch (e) {
    report(e);
  }
}, 15_000);

function connect() {
  const url = new URL(process.env.CARBIUM_WS_URL ?? "wss://services.carbium.sh");
  url.searchParams.set("api-key", apiKey);
  const ws = new WebSocket(url);
  ws.onopen = () =>
    ws.send(JSON.stringify({ jsonrpc: "2.0", id: 1, method: "logsSubscribe", params: [{ mentions: [wallet] }, { commitment: "confirmed" }] }));
  ws.onmessage = (ev) => {
    const m = JSON.parse(String(ev.data));
    if (m.method === "logsNotification") {
      const { context, value } = m.params.result; // the log lines stay behind: the page gets three fields
      publish({ signature: value.signature, slot: String(context.slot), err: value.err }).catch(report);
    } else if (m.error) {
      console.error("subscribe refused:", m.error.message);
    }
  };
  ws.onclose = () => {
    console.error("socket closed, reconnecting in 2 s");
    setTimeout(connect, 2_000);
  };
}
connect();
```

## What it costs on Carbium

Opening a `logsSubscribe` with a mentions filter [takes 25 credits](https://carbium.sh/docs/limits), and the notifications then bill at 20 credits per MiB sent. A refused subscription costs nothing. The relay holds one socket per process and one subscription per wallet it follows. Free carries 5 sockets, and your plan caps subscriptions per account, so the count of wallets one account can follow depends on the plan. The fallback read is one `getSignaturesForAddress` call at 50 cells.

## Where it ends

- A transfer of tokens into a token account that already exists lists the token accounts and the sender's authority. It never lists the wallet that owns the receiving account, so a mention subscription on the wallet stays silent for it. To catch deposits, find the wallet's token accounts with `getTokenAccountsByOwner` ([Token accounts by owner](https://carbium.sh/library/howsolana/token-accounts-by-owner) shows the call), subscribe to each one, and trigger on the wallet's channel. A wallet can own several token accounts for one mint, and the instruction that creates a new token account normally lists its owner, so the wallet's own subscription sees the creation and can start a fresh lookup.
- Delivery is at most once. While the relay is down or its socket is reconnecting, transactions go by unseen, and Pusher keeps no history for a page that was offline. Store the newest signature you published, and after a restart or a page load read `getSignaturesForAddress` with `until` set to it. That index reaches back 30 days at most, so a longer gap cannot be refilled.
- Two relays on one wallet publish every event twice. Run one per wallet, or dedupe on the signature in the page.
- Pusher's own connection and message quotas apply to the Pusher side and come from your Pusher plan.
- If you would rather skip a Pusher account, [Hono server-sent account events](https://carbium.sh/library/integrate/hono-server-sent-account-events) pushes to browsers over server-sent events from your own server.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The relay logs `socket closed, reconnecting in 2 s` over and over and no event prints. | The handshake is refused. An [unknown key gets a 401](https://carbium.sh/docs/errors) at the door, so check that `CARBIUM_KEY` holds the whole key and that `CARBIUM_WS_URL`, if set, points at `wss://services.carbium.sh`. |
| Events print in the relay but the log also shows `pusher 401`. | Pusher rejected the signature. Check that `PUSHER_KEY` and `PUSHER_SECRET` belong to the same app, that `PUSHER_CLUSTER` is the cluster that app lives in, and that the machine clock is correct, since Pusher refuses a timestamp that is more than 10 minutes off. |
| The browser's private channel subscription fails and the page shows an auth error. | Your auth endpoint must answer 200 with JSON of the form `{ auth }`, computed from the `socket_id` and `channel_name` that pusher-js posted, under the same app secret the relay uses. A 403 from the endpoint means your own user check refused the wallet. |
| The relay prints events and the page receives none. | Compare the channel name in the relay's output with the one the page subscribes to, character for character, and check that the page uses the same app key and cluster as the relay. |
| The log shows `subscribe refused:` followed by a message about a limit. | The plan caps subscriptions or sockets per account. Follow fewer wallets from this account or move to a plan with more room. The refused subscription cost nothing, and the ones already accepted keep sending. |
| A wallet receives tokens and its channel stays quiet. | The transfer went into an existing token account and never listed the wallet. Subscribe to the wallet's token accounts as well, as the last section describes. |

## Questions

### Can the browser call onLogs from solana-web3.js itself?

It can, and it then needs your Carbium key in the page and a socket per open tab against the plan's socket cap. Keeping the subscription on a server and fanning out through Pusher holds the key and the socket count in one place.

### Does spl-token have anything that pushes?

No. It builds instructions and decodes token accounts. Push comes from a WebSocket subscription on the node, which your server opens.

### Why a private channel, when the chain is public?

Anyone can read the chain, but the list of wallets one user watches is your product's data. A private channel makes your server decide which user may subscribe to which wallet.

### Why does the event leave out the log lines?

A page rarely needs them, and they make the event larger. The signature lets a page or your server fetch the full transaction when someone asks for it.

### Do events replay after a relay restart?

No. Read `getSignaturesForAddress` with `until` set to the last signature you published and trigger the missing ones in order.

## Related

- [Hono server-sent account events](https://carbium.sh/library/integrate/hono-server-sent-account-events) (Integrations, I0064)
- [Token accounts by owner](https://carbium.sh/library/howsolana/token-accounts-by-owner) (How to use Solana, HS0017)
- [carbium.sh/docs/websocket](https://carbium.sh/docs/websocket)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
- [carbium.sh/docs/errors](https://carbium.sh/docs/errors)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
