---
id: BI0012
title: "Read-only hackathon starter"
url: https://carbium.sh/library/blockchainideas/read-only-hackathon-starter
collection: Blockchain ideas
category: Hackathon starters
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Read-only hackathon starter

A hackathon team needs working Solana reads before it can build anything else. This starter is one Node file that prints a wallet's balance and last transactions, then streams its activity live, with five project ideas that reuse it and what each costs.

## Who it is for

A hackathon team of two to four people has a short build window and an idea it has not picked yet. The first blocker is a clean read path to Solana that every teammate can run.

The starter needs no wallet and no node of your own. One Carbium key reaches RPC and the WebSocket on `services.carbium.sh`. The team runs one file, sees real mainnet data in the terminal, and then picks what to build on top.

Because it never signs, it needs no funded wallet and puts no private key at risk on a shared laptop at a demo.

## What the starter does

The file takes one public address and runs four calls in order. Every project below reuses them.

| Step | Call | What you see |
|---|---|---|
| 1 | `getSlot` | the current slot at `confirmed` |
| 2 | `getBalance` | the address's SOL balance |
| 3 | `getSignaturesForAddress` | the last 5 transactions with time and `ok` or the error |
| 4 | `logsSubscribe` with `mentions` | one line per new transaction that mentions the address, with its signature and result |

Steps 1 to 3 are one-shot reads. Step 4 holds one socket open until you stop it or `WATCH_SECONDS` runs out.

## The build

The code needs `@solana/kit` and what Node 24 ships. Node strips the types on load, so `node main.ts` runs the file as written.

1. Read `CARBIUM_KEY` and exit with a message when it is unset.
2. Create the RPC client once and reuse it for every call.
3. Call `getSlot`, `getBalance` and `getSignaturesForAddress` in turn, each at commitment `confirmed`, with `limit: 5` on the last.
4. Open one WebSocket and send `logsSubscribe` with `{ mentions: [address] }`. The first reply carries the subscription id, or an error when the subscription is refused, which costs nothing.
5. Print one line per `logsNotification`, with the signature and `ok` or the error.

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

```ts
// BI0012 · Read-only hackathon starter
// https://carbium.sh/library/blockchainideas/read-only-hackathon-starter
// 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);
}
const target = process.argv[2];
if (!target) {
  console.error("Usage: node main.ts <public address>");
  process.exit(1);
}
const watched = address(target);
const WS_URL = `${process.env.CARBIUM_WS_URL ?? "wss://services.carbium.sh"}/?api-key=${key}`;
const seconds = Number(process.env.WATCH_SECONDS ?? 0); // 0 watches until you stop it
// kit fills in confirmed when a call leaves it out; the server's own default is finalized.
const commitment = "confirmed";
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": key },
  }),
);

const json = (v: unknown): string => JSON.stringify(v, (_k, x) => (typeof x === "bigint" ? x.toString() : x));
const result = (err: unknown): string => (err ? json(err) : "ok");

async function main(): Promise<void> {
  const slot = await rpc.getSlot({ commitment }).send();
  const balance = await rpc.getBalance(watched, { commitment }).send();
  console.log(`slot ${slot}, ${watched} holds ${Number(balance.value) / 1e9} SOL`);
  const recent = await rpc.getSignaturesForAddress(watched, { limit: 5, commitment }).send();
  for (const s of recent) {
    const when = s.blockTime === null ? "unknown time" : new Date(Number(s.blockTime) * 1000).toISOString();
    console.log(`${when} ${s.signature} ${result(s.err)}`);
  }

  const ws = new WebSocket(WS_URL);
  ws.onopen = () => ws.send(JSON.stringify({
    jsonrpc: "2.0", id: 1, method: "logsSubscribe",
    params: [{ mentions: [watched] }, { commitment }],
  }));
  ws.onmessage = (ev) => {
    const msg = JSON.parse(String(ev.data));
    if (msg.id === 1) {
      console.log(msg.error ? `subscribe refused: ${msg.error.message}` : `watching, subscription ${msg.result}`);
    } else if (msg.method === "logsNotification") {
      const { signature, err } = msg.params.result.value as { signature: string; err: unknown };
      console.log(`live ${signature} ${result(err)}`);
    }
  };
  ws.onclose = () => console.log("socket closed");
  ws.onerror = () => ws.close();
  if (seconds > 0) setTimeout(() => process.exit(0), seconds * 1000);
}

main().catch((e) => {
  console.error("failed:", e instanceof Error ? e.message : e);
  process.exit(1);
});
```

The endpoints come from `CARBIUM_RPC_URL` and `CARBIUM_WS_URL`, which default to `https://services.carbium.sh` and `wss://services.carbium.sh`.

Run it first on the Memo program from the run command, so live lines show up within seconds. Then point it at your own wallet or at the program your idea is about.

## Five ideas that grow from it

| Idea | What you add | Watch for |
|---|---|---|
| Wallet activity feed | keep the socket, add a page, and backfill with `getSignaturesForAddress` after a restart | history reaches back 30 days at most |
| Program failure board | count `err` per program; the [Failed-mint monitor](https://carbium.sh/library/blockchainideas/failed-mint-monitor) is a full version | the stream carries successful transactions too |
| Token balance tracker | call `getTokenAccountBalance` when a notification arrives, as in [SPL token balance](https://carbium.sh/library/howsolana/spl-token-balance) | account reads cost 10 cells each |
| Confirmation page | one `signatureSubscribe` per pasted signature | it sends one confirmation, then the subscription ends |
| SOL balance alert | `logsSubscribe` mentions, then `getBalance` on each hit | `accountSubscribe` stays silent for a plain SOL wallet |

Pick the one where a judge can see a result by pasting an address into a box. Ideas 1, 3 and 5 work that way.

## What it costs

Each [RPC method](https://carbium.sh/docs#rpc) has a cell cost, and your plan sets how many requests per second that cost allows. A WebSocket subscription costs credits: a logs-mentions filter opens at 25 credits, then costs 20 credits per MiB sent. A refused subscription is free.

| Plan | Credits | `getSlot` (1 cell) | `getSignaturesForAddress` (50 cells) | Account reads (10 cells) |
|---|---|---|---|---|
| Free ($0) | 500K once, at sign-up | 5 req/s | 0.24 req/s | 0.5 req/s |
| Dev ($20) | 10M per month | 30 req/s | 1.2 req/s | 15 req/s |
| Business ($250) | 50M per month | 100 req/s | 100 req/s | 50 req/s |
| Pro ($500) | 200M per month | 500 req/s | 500 req/s | 400 req/s |

One run of the starter is one `getSlot`, one `getBalance`, one `getSignaturesForAddress` and one subscription.

The live part is the one to size. Assume 2 KiB per notification and measure the real size on your address. A wallet with ten mentions a minute sends about 1.2 MiB an hour, which is about 23 credits. A busy program at 100 mentions a second sends about 703 MiB an hour, which is about 14,000 credits, or 2.8% of the Free grant.

Limits are per account, so every key on the account shares one budget. Free carries 5 sockets, so a team of four running one watcher each uses four of them.

## Where it ends

- The starter is read-only. Quotes answer on the same endpoint as four JSON-RPC methods (`quote`, `swap`, `health` and `prices`), and `swap` returns one unsigned transaction that your own software has to sign and send, which is a step this starter leaves out.
- History is the 30-day address index at most. An empty page from `getSignaturesForAddress` past that is the index's age limit and says nothing about the address's first transaction.
- `accountSubscribe` stays silent for a plain SOL wallet, so idea 5 uses the mentions filter plus `getBalance`.
- The mentions filter takes one address per subscription. Watching several wallets means several subscriptions, each with its own opening credits.
- `getTokenLargestAccounts`, `getProgramAccountsV2` and six more methods are not served and answer `-32601`. An idea that ranks the largest holders of a token needs another route.
- The WebSocket suits one wallet or one program. A firehose belongs on the gRPC stream at `https://services.carbium.sh:9443`, which takes the key in the `x-token` header and opens on Dev, Business and Pro. Free is off.
- The starter does not reconnect. A closed socket ends the live part, and adding a reconnect with a short delay is the first change for a demo that has to stay up.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The script exits at once and asks for `CARBIUM_KEY`. | Export the key in the shell that runs the file. The code never prints it, so check it with `test -n "$CARBIUM_KEY"`. |
| `getSignaturesForAddress` answers 429 on Free. | It costs 50 cells and Free allows 0.24 req/s. Wait the retry-after seconds, and call it once per run instead of in a loop. |
| The subscribe reply is an error, or the socket closes straight away. | Check the key and the socket cap (Free carries 5). A refused subscription is free, so a retry costs nothing. |
| The history stops after a few lines for an old address. | The address index keeps up to 30 days. An empty page past that is its age limit, so older activity needs a source of your own. |
| No live lines print. | Either the address is quiet or the filter names the wrong one. Run the file on a program with steady traffic, such as the one in the run command, to confirm the socket works. |
| An error says the method is not found with code -32601. | The method is not served. Do not retry it. Check the spelling, then pick a method the endpoint serves. |

## Questions

### Do I need a funded wallet or a private key?

No. The starter only reads, so it needs no private key, no funds and no signing. Your Carbium key is the only secret in the project, so keep it in the environment and out of the repository.

### Will it run on the Free plan?

Yes. One run makes one `getSignaturesForAddress` call at 50 cells, which Free allows at 0.24 req/s, and opens one subscription at 25 credits from the 500K one-time grant.

### Why use the WebSocket for live data instead of polling?

Polling `getSignaturesForAddress` costs 50 cells a call, and a one-second loop is over the Free rate of 0.24 req/s. The subscription sends only the transactions that mention the address.

### Can I watch several wallets at once?

Yes, with one subscription per address, since the mentions filter takes a single address. Each one pays its own opening credits and counts against the socket cap of your plan.

### Can the whole team share one key?

Yes. Every key on an account draws on one budget, so four teammates running the watcher share the rates in the cost table.

## 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#rpc](https://carbium.sh/docs#rpc)
- [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#stream](https://carbium.sh/docs#stream)
- [carbium.sh/docs#migrate](https://carbium.sh/docs#migrate)
