services
Get a key

library / Integrations / No-code automation / I0152

Retool account data viewer

A Node process reads up to 100 accounts with one getMultipleAccounts call per request, decodes SPL mint supply, and serves JSON on localhost for a Retool REST query.

By Carbium · No-code automation · I0152 · updated 2026-11-23

01

What the viewer does

The viewer is one Node process with a single dependency, @solana/kit. It reads the accounts you name from Carbium, decodes the SPL mint layout where it applies, and answers with JSON. A Retool app then shows the fields in a table through a REST query, so the app needs no Solana code of its own.

Each row carries the address, the lamports as a string, the owner program and the data length. When the owner is the SPL Token program and the data is 82 bytes long, the row also carries the supply and the decimals of a mint. An address with no account comes back with nulls, so the table shows the gap instead of an error.

FieldWhere it sits in the accountShape in the answer
lamportsthe balance on the accounta decimal string
ownerthe program that owns the accounta base58 address
mint.supplyu64 at byte 36 of the dataa decimal string
mint.decimalsbyte 44 of the dataa number
02

One read, one commitment

The viewer sends one getMultipleAccounts call for up to 100 addresses per request. Account reads cost 10 cells per pubkey, so a full 100-address call costs 1,000 cells. Pro's plan takes up to 300 pubkeys in one call, but below Pro the 1024-cell burst caps a call at 100, so the viewer stops at 100 on every plan.

Every call sets commitment to confirmed and encoding to base64 in the code. The encoding asks for the raw bytes, so the decoding happens in one place and Retool never parses base64. The commitment is written out, so each refresh reads the same level.

The limits on a Carbium account are shared across its keys, so a Retool app and a second service on the same account draw from one budget. A Retool page that refreshes every few seconds spends cells on every refresh, and Free allows 0.5 req/s for account reads.

03

Wiring Retool to the server

Start the viewer with PORT set and it listens on 127.0.0.1 at /accounts. In Retool, add a REST API resource whose base URL is that address, then add a GET query to /accounts with one address query parameter per account. The viewer reads the first 100 it receives and ignores the rest.

The key header stays in the viewer's environment. Retool never sees CARBIUM_KEY, so do not paste the key into the resource headers; the Retool app talks only to the viewer.

Bind the viewer where your Retool can reach it. A self-hosted Retool on the same machine calls 127.0.0.1 directly, and a Retool on another host needs the viewer behind a proxy you control.

Keep the address column as the table key. The viewer returns one row for each address you sent, in the order you sent it, so an address appears once per refresh.

04

The viewer

Install with npm install @solana/[email protected] and set the type field to module in package.json. Node 24 strips the types on load. Run the file with no arguments to print the two default accounts, the USDC mint and the SPL Token program, or pass addresses after the file name. Set PORT to serve the Retool endpoint instead.

main.ts
// I0152 · Retool account data viewer// https://carbium.sh/library/integrate/retool-account-data-viewer// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";import { createServer } from "node:http";const key = process.env.CARBIUM_KEY;if (!key) {  console.error("Set CARBIUM_KEY in the environment, then start the viewer again.");  process.exit(1);}const rpc = createSolanaRpcFromTransport(  createDefaultRpcTransport({    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",    headers: { "x-api-key": key },  }),);const TOKEN_PROGRAM = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";const MINT_BYTES = 82;const DEFAULTS = ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", TOKEN_PROGRAM];type Row = {  address: string;  lamports: string | null;  owner: string | null;  bytes: number | null;  mint: { supply: string; decimals: number } | null;};async function read(addresses: string[]): Promise<Row[]> {  if (addresses.length === 0) return [];  const list = addresses.map((a) => address(a));  const { value } = await rpc    .getMultipleAccounts(list, { encoding: "base64", commitment: "confirmed" })    .send();  return value.map((acct, i) => {    const row: Row = { address: addresses[i], lamports: null, owner: null, bytes: null, mint: null };    if (!acct) return row;    const data = Uint8Array.from(atob(acct.data[0]), (c) => c.charCodeAt(0));    row.lamports = acct.lamports.toString();    row.owner = acct.owner;    row.bytes = data.length;    if (acct.owner === TOKEN_PROGRAM && data.length === MINT_BYTES) {      const view = new DataView(data.buffer);      row.mint = { supply: view.getBigUint64(36, true).toString(), decimals: data[44] };    }    return row;  });}const server = createServer(async (req, res) => {  const url = new URL(req.url ?? "/", "http://127.0.0.1");  if (url.pathname !== "/accounts") {    res.writeHead(404).end();    return;  }  const addresses = url.searchParams.getAll("address").slice(0, 100);  try {    const rows = await read(addresses);    res.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify(rows));  } catch (err) {    console.error("read failed:", err instanceof Error ? err.message : err);    res.writeHead(502, { "content-type": "application/json" }).end(JSON.stringify({ error: "read failed" }));  }});if (process.env.PORT) {  server.listen(Number(process.env.PORT), "127.0.0.1", () =>    console.log(`listening on 127.0.0.1:${process.env.PORT}/accounts`),  );} else {  const args = process.argv.slice(2);  const rows = await read(args.length > 0 ? args : DEFAULTS);  console.log(JSON.stringify(rows, null, 2));}

run: node main.ts

05

Where it ends

  • The viewer has no login. It listens on 127.0.0.1, but anyone on that machine who reaches the port reads any account, so put a check in front of it before a shared network can reach it.
  • It decodes one layout, the SPL mint. A token account, a stake account or a program's own data comes back as owner and length only, and the viewer does not guess at those layouts.
  • It reads the current state of each account. The transaction history of an address is a separate read, and the signature index Carbium serves keeps 30 days at most, so older history is not in this table.
  • Each request makes one RPC call and does not retry. A failed call returns 502 with no detail, so the error text lives in the viewer's log.
  • Free allows 0.5 req/s for account reads, so a page that refreshes often needs a higher plan or a manual refresh button.
06

When it goes wrong

what goes wrongwhat to do
The viewer exits at start with a message about CARBIUM_KEY.The variable is unset in this shell or service. Export it or set it in the unit file, then start the viewer again.
Every request returns 502 from the first call, and the log shows a read failure.An unknown key gets 401 at the door, so no account is read. Attach the whole key in CARBIUM_KEY and check that it is not an old one.
A refresh returns 502 during a busy minute, and the next refresh works.The account's budget was spent for a moment. A call over its rate waits once if its cells refill within 1 s, then gets 429 with a retry-after hint. Limits are per account, so lower the refresh rate or move to a plan with more req/s.
A wallet address shows no mint fields.Mint fields apply only to a mint account. A wallet is owned by the System program, which has no mint layout, so use token balance reads for its tokens.
A Token-2022 mint shows owner and length but no supply.Token-2022 mints have their own owner program, so the viewer leaves their layout alone. Decoding them needs the extension layout, which this viewer does not read.
07

Questions

Can Retool call Carbium directly?

It can, but then the key sits in the Retool resource and every app user can read it. The viewer keeps the key on one server, and the Retool app sends only account addresses.

Why does lamports come back as a string?

A lamport count can be larger than a JavaScript number holds exactly. The viewer sends the digits as a string so the value stays exact in Retool.

How many accounts can one refresh read?

Up to 100 in one call. At 10 cells each, a full refresh costs 1,000 cells, and the burst cap below Pro is the same 100 limit.

Does the viewer show account history?

No. It reads the current state. For the transactions that touched an address, use a signature query, and expect it to reach 30 days at most.