---
id: HS0032
title: "Lookup table contents reader"
url: https://carbium.sh/library/howsolana/lookup-table-contents-reader
collection: How to use Solana
category: Versioned transactions and lookup tables
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Lookup table contents reader

One TypeScript file reads an address lookup table account, decodes its header and addresses, and prints the first ten by index. With no argument it finds a table in use from a busy program's newest transaction and prints the entries that transaction pulled in too.

## What a lookup table holds

A v0 transaction can name its accounts in a compact way. Instead of listing every 32-byte address in the message, it points at an address lookup table and gives one-byte indexes into it. The table is an ordinary account owned by the address lookup table program, and it stores up to 256 addresses. That is how a swap touching dozens of accounts still fits inside a v0 transaction's 1232-byte limit.

Reading a table answers questions an explorer shows as raw numbers. Which address sits at index 3? Who may extend the table? Is it still active? Does an index a transaction used still resolve to the address you expect? All of it lives in one account, so one `getAccountInfo` call is enough. The decoding is byte arithmetic on a fixed layout, and the file below does it by hand in about twenty lines.

## The code

Install `@solana/kit` at 8.6.0, export `CARBIUM_KEY` and run the file with Node 24, which strips the types on load. Pass a table address, or pass nothing. With no argument it takes the eight newest signatures of the Jupiter v6 program, fetches transactions one at a time until one carries `addressTableLookups`, and reads the first table that transaction names. It then marks the entries that transaction used.

`main.ts` (run: `node main.ts [lookup-table-address]`)

```ts
// HS0032 · Lookup table contents reader
// https://carbium.sh/library/howsolana/lookup-table-contents-reader
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

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

function fail(msg: string): never {
  console.error(msg);
  process.exit(1);
}
const apiKey = process.env.CARBIUM_KEY ?? fail("Set CARBIUM_KEY to your Carbium API key.");
const client = createSolanaRpcFromTransport(
  createDefaultRpcTransport({
    url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh",
    headers: { "x-api-key": apiKey },
  }),
);

const TABLE_PROGRAM = "AddressLookupTab1e1111111111111111111111111";
const JUPITER_V6 = address("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4");
const HEADER_BYTES = 56;
const STILL_ACTIVE = 0xffffffffffffffffn;
const base58 = getBase58Decoder();

type Pick = { table: string; used: number[] };
type Lookup = { accountKey: string; writableIndexes: number[]; readonlyIndexes: number[] };

async function step<T>(name: string, run: () => Promise<T>): Promise<T> {
  return run().catch((e: Error) => fail(`${name} failed: ${e.message}`));
}

async function discover(): Promise<Pick | null> {
  const recent = await step("getSignaturesForAddress", () =>
    client.getSignaturesForAddress(JUPITER_V6, { limit: 8 }).send(),
  );
  const skipped: string[] = [];
  for (const { signature } of recent) {
    try {
      const tx = await client
        .getTransaction(signature, { encoding: "json", maxSupportedTransactionVersion: 1 })
        .send();
      if (!tx) {
        skipped.push(`${signature}: null`);
        continue;
      }
      const msg = tx.transaction.message as unknown as { addressTableLookups?: Lookup[] };
      const first = msg.addressTableLookups?.[0];
      if (first && isAddress(first.accountKey)) {
        return { table: first.accountKey, used: first.writableIndexes.concat(first.readonlyIndexes) };
      }
    } catch (e) {
      skipped.push(`${signature}: ${(e as Error).message}`);
    }
  }
  console.error(`checked ${recent.length} signatures, skipped ${skipped.length}`);
  for (const s of skipped) console.error(`  skipped ${s}`);
  return null;
}

const given = process.argv[2];
if (given && !isAddress(given)) fail(`${given} is not an address.`);
const pick: Pick =
  (given ? { table: given, used: [] } : await discover()) ??
  fail("No transaction with a lookup table in the newest signatures; run again or pass a table address.");

const { value: account } = await step("getAccountInfo", () =>
  client.getAccountInfo(address(pick.table), { encoding: "base64" }).send(),
);
if (!account || account.owner !== TABLE_PROGRAM) fail(`${pick.table} is not an address lookup table account.`);
const raw = new Uint8Array(Buffer.from(account.data[0], "base64"));
const dv = new DataView(raw.buffer);
const count = (raw.length - HEADER_BYTES) / 32;
if (!Number.isInteger(count) || count < 0 || dv.getUint32(0, true) !== 1) {
  fail("The account data does not have the lookup table layout.");
}

const entryAt = (i: number) => base58.decode(raw.subarray(HEADER_BYTES + i * 32, HEADER_BYTES + (i + 1) * 32));
const off = dv.getBigUint64(4, true);
const lines = [
  `table ${pick.table}`,
  `  authority: ${raw[21] === 1 ? base58.decode(raw.subarray(22, 54)) : "none (frozen)"}`,
  `  deactivation slot: ${off === STILL_ACTIVE ? "active" : off}`,
  `  last extended slot: ${dv.getBigUint64(12, true)} (from index ${raw[20]})`,
  `  addresses: ${count}`,
];
for (let i = 0; i < count; i++) {
  const hit = pick.used.includes(i);
  if (i < 10 || hit) lines.push(`  [${i}] ${entryAt(i)}${hit ? "  <- used" : ""}`);
}
console.log(lines.join("\n"));
```

The transaction fetch sends `maxSupportedTransactionVersion: 1`, so v0 and v1 transactions both come back. Every call here runs at `confirmed`, which @solana/kit 8.6.0 fills in when commitment is left out. The account read asks for `base64` so the bytes arrive raw. The file checks the owner and the data length before it decodes a single address, so a wallet or a token account fails with a plain message. If the signature listing or the account read itself fails, the file prints which call it was and the error.

Discovery does not skip failed transactions. A failed transaction still carries its message, lookups included, and a busy swap program fails often enough that skipping them can leave nothing to read.

## The account layout

A table is a 56-byte header followed by the addresses, 32 bytes each, to the end of the data. Every integer is little-endian.

| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 4 | type | `1` for a lookup table. |
| 4 | 8 | deactivation slot | The largest u64, 18446744073709551615, while the table is active. Any smaller value is the slot where deactivation began. |
| 12 | 8 | last extended slot | The slot of the most recent extension. |
| 20 | 1 | start index | Index of the first address added in that slot. |
| 21 | 1 | authority flag | `1` when an authority exists, `0` when the table is frozen. |
| 22 | 32 | authority | The address allowed to extend, freeze, deactivate and close the table. Read it only when the flag is `1`. |
| 54 | 2 | padding | Unused. |
| 56 | 32 each | addresses | Entry 0 first. The count is the remaining length divided by 32. |

An account that fails the length check, where the bytes after the header are not a multiple of 32, is not a table. The file rejects it. A full table holds 256 addresses, which is 8248 bytes of data, and one `getAccountInfo` returns all of it.

> Entries are only ever appended. An index a past transaction used keeps its address for as long as the table exists, which makes a table safe to read long after the transaction ran.

## From a transaction to its addresses

A transaction names tables in `addressTableLookups`. Each entry holds a table address, a list of writable indexes and a list of readonly indexes. After the message's own account keys, the runtime appends the writable addresses of every lookup in `addressTableLookups` order, then the readonly addresses of every lookup in that same order. An instruction's account index N therefore points at a static key when N is below their count, then into the writable loaded addresses, then into the readonly ones.

The file marks the used entries while it walks the table, so they print in table index order and carry no writable or readonly label. To turn a transaction into a full account list, start with the static keys. Add each lookup's writable indexes resolved against its own table, lookup by lookup in order. Then add each lookup's readonly indexes the same way. A Jupiter swap often carries several lookups, so the writable addresses of all of them come before the first readonly address of any. A table you pass by hand has no transaction attached, so nothing gets marked and the first ten entries print.

A fresh extension needs one more rule. Addresses added in a slot cannot be used by a transaction in that same slot. The header's last extended slot and start index tell you which tail entries are that new, and a lookup of one of them in the current slot fails.

A table whose deactivation slot is set still resolves for a cooldown of a few hundred slots. After that the authority can close it and the account disappears, which is why a long-lived integration reads the header before it relies on a table. For the errors a transaction version can raise on the way in, see [Transaction version error -32015](https://carbium.sh/library/howsolana/transaction-version-error-32015).

## On Carbium

A `getAccountInfo` read costs 10 cells and runs at 0.5 req/s on Free, 15 on Dev, 50 on Business and 400 on Pro.

The discovery path costs more. One `getSignaturesForAddress` is 50 cells, and each `getTransaction` is another 50. The file stops at the first transaction that carries a lookup and tries eight at most, so the worst case is 450 cells for discovery, 460 with the table read. Each rate class absorbs a burst of at least 1,024 cells, so the eight `getTransaction` calls (400 cells) and the one listing (50) each fit. Pass a table address and the discovery calls never happen. Every [RPC method](https://carbium.sh/docs#rpc) has its own cell cost, and the [plan limits](https://carbium.sh/docs#limits) set the rates.

## Where it ends

The file shows a table as it stands now, at `confirmed`. It cannot show what the table held when an old transaction ran. Because entries are appended, an index from the past still maps to the same address, but a table that has been closed leaves nothing to read.

Discovery reads only the eight newest signatures of a busy program, so it never reaches old history, and it skips any signature whose `getTransaction` answer is null.

Solana has no call that lists the tables holding a given address. Finding one that does means scanning every account of the lookup table program, and this file does not attempt that. Pass a table address you already know.

It only reads. Creating a table, extending it, freezing it or closing it needs a signed transaction, and this file holds no keypair.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| The file prints that the address is not an address lookup table account. | The account is missing or owned by another program. Pass the table's own address, the `accountKey` a transaction lists inside `addressTableLookups`. |
| getTransaction answers -32015 for a signature. | The transaction version is newer than the call accepts. Send `maxSupportedTransactionVersion: 1`, as the file does. Absent or 0 fails for a v1 transaction or a block holding one. |
| Discovery prints that no transaction with a lookup table turned up. | None of the eight newest transactions used a table, or each returned null or an error, which the file lists as skipped. Run it again for newer signatures, or pass a table address. |
| A listed signature returns null from getTransaction. | The signature is below the validator's ledger floor, which the address index can still list. Use newer signatures, and keep the null handling. |
| HTTP 429 with a retry-after hint. | Running discovery again and again on a low plan can push its calls over their rate; pass a table address to skip them. |
| A table address copied from an old transaction reads as missing. | The authority closed the table after deactivating it, so the account no longer exists and the read comes back empty. The addresses it held are gone from the chain's current state; take a table from a newer transaction. |

## Questions

### How many addresses can one table hold?

256, because a transaction points at an entry by a one-byte index. A table that is full needs a second table for more.

### How do I find the table a transaction used?

Fetch the transaction with `getTransaction` and read `addressTableLookups` in its message. Each entry names a table by `accountKey`, then lists the writable and readonly indexes it pulled from it.

### Why is the deactivation slot 18446744073709551615?

That is the largest u64 and means the table is active. A smaller number is the slot where the authority began deactivating it.

### What does a frozen table mean?

The authority flag is 0. Nobody can extend, deactivate or close the table, so its contents are final.

## Related

- [Transaction version error -32015](https://carbium.sh/library/howsolana/transaction-version-error-32015) (How to use Solana, HS0012)
- [Swap transaction decoder](https://carbium.sh/library/si/swap-transaction-decoder) (AI and blockchain, SI0012)
- [carbium.sh/docs#rpc](https://carbium.sh/docs#rpc)
- [carbium.sh/docs#limits](https://carbium.sh/docs#limits)
- [carbium.sh/docs#endpoints](https://carbium.sh/docs#endpoints)
- [carbium.sh/docs#auth](https://carbium.sh/docs#auth)
