---
id: HS0027
title: "Transaction size checker"
url: https://carbium.sh/library/howsolana/transaction-size-checker
collection: How to use Solana
category: Build, sign and send transactions
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Transaction size checker

One TypeScript file fetches landed transactions as raw bytes and prints each one's size, headroom under 1232 bytes, signature count and account count. You get a measured baseline, then ways to shrink or split a transaction that does not fit.

## Where 1232 comes from

A Solana transaction has to fit in one network packet. The IPv6 minimum MTU is 1280 bytes. Take away 40 bytes for the IPv6 header and 8 for the fragment header and 1232 bytes remain for the signed transaction. Every legacy and version 0 transaction gets the same cap, and one over it never reaches a leader.

A v1 transaction is the format that goes past 1232 bytes. On mainnet it runs under a larger cap, so v1 is part of the answer when a job will not fit, and a size check has to compare each transaction with the cap of its own version.

The bytes are spent in a fixed order. Each signature takes 64 bytes. A small header follows, then a 32-byte key for every account the message names, a 32-byte blockhash, and then every instruction with its program index, account indexes and data. Accounts dominate. A swap that touches fifteen accounts spends 480 bytes on keys before it carries a single byte of instruction data.

That makes the answer to "my transactions are too big" a measurement first. If you know how many bytes a typical transaction in your category uses, and how many are keys, the choice between trimming, a lookup table and splitting is arithmetic.

## The code

Install `@solana/kit` at 8.6.0, export `CARBIUM_KEY` and run the file with Node 24. Give it signatures, or one address. For an address it takes the five latest signatures. With no argument it uses a busy program, so you can run it before you have a transaction of your own.

`main.ts` (run: `node main.ts <signature>... | <address>`)

```ts
// HS0027 · Transaction size checker
// https://carbium.sh/library/howsolana/transaction-size-checker
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

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

const LIMIT = 1232;
const key = process.env.CARBIUM_KEY;
if (!key) {
  console.error("Set CARBIUM_KEY to your Carbium API key.");
  process.exit(1);
}
const url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";
const rpc = createSolanaRpcFromTransport(
  createDefaultRpcTransport({ url, headers: { "x-api-key": key } }),
);

// No argument: the five newest signatures of a busy program (Jupiter v6).
const args = process.argv.slice(2);
const [first = "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"] = args;
const sigs =
  args.length <= 1 && isAddress(first)
    ? (
        await rpc.getSignaturesForAddress(first, { limit: 5, commitment: "confirmed" }).send()
      ).map((row) => row.signature)
    : args.map((a) => signature(a));

// Legacy and v0 wire layout: compact signature count, 64 bytes each, then the message.
// A v1 transaction starts with its 0x80 | 1 version byte and is not parsed here.
function measure(b64: string) {
  const bytes = Buffer.from(b64, "base64");
  const size = bytes.length;
  if ((bytes[0] & 0x80) !== 0) {
    return { size, capped: false, left: "?", version: String(bytes[0] & 0x7f), sigCount: "?", keys: "?" };
  }
  const sigCount = bytes[0];
  const at = 1 + sigCount * 64;
  const prefix = bytes[at];
  const versioned = (prefix & 0x80) !== 0;
  const version = versioned ? String(prefix & 0x7f) : "legacy";
  const keysAt = at + (versioned ? 4 : 3);
  const keys = !versioned || version === "0" ? String(bytes[keysAt]) : "?";
  return { size, capped: true, left: String(LIMIT - size), version, sigCount: String(sigCount), keys };
}

const results = await Promise.allSettled(
  sigs.map((s) =>
    rpc
      .getTransaction(s, { encoding: "base64", maxSupportedTransactionVersion: 1, commitment: "confirmed" })
      .send(),
  ),
);

let largest = 0;
for (const [i, r] of results.entries()) {
  const label = sigs[i].slice(0, 12);
  if (r.status === "rejected") {
    console.log(`${label} failed: ${r.reason instanceof Error ? r.reason.message : String(r.reason)}`);
  } else if (r.value === null) {
    console.log(`${label} not returned by the node (older than its ledger)`);
  } else {
    const m = measure(r.value.transaction[0]);
    if (m.capped) largest = Math.max(largest, m.size);
    console.log(
      `${label} bytes=${m.size} left=${m.left} version=${m.version} sigs=${m.sigCount} keys=${m.keys}`,
    );
  }
}
if (largest > 0) {
  const room = Math.floor((LIMIT - largest) / 32);
  console.log(`largest legacy or v0 ${largest} bytes: room for ${room} more static keys under ${LIMIT}`);
}
```

The size comes from asking `getTransaction` for `encoding: "base64"` at confirmed commitment. The reply is the transaction exactly as it went over the wire, so its decoded length is the number to compare with 1232. A first byte with the top bit set identifies a v1 transaction, and the file labels it version 1 and prints `?` for left, sigs and keys. For legacy and version 0 the first byte is the signature count, and the account count is read from the message header, after the 64 bytes per signature. Each call is settled on its own, so a signature the node cannot return does not stop the rest.

## Reading a row

| Column | Meaning |
|---|---|
| bytes | Length of the serialized transaction, signatures included. |
| left | 1232 minus bytes for a legacy or version 0 row. Shown as `?` for a v1 row, which has a larger cap of its own. |
| version | `legacy`, or the number from the version prefix of a versioned message. A v1 transaction shows `1`. |
| sigs | Signatures carried, at 64 bytes each. Shown as `?` for a v1 row. |
| keys | Static account keys in the message, at 32 bytes each. Shown as `?` for a layout the file does not parse. |

The last line prints the largest legacy or version 0 row and how many more static keys would fit in its headroom, at 32 bytes a key. Those rows landed, so each is at most 1232 and the line cannot go negative. The interesting number is `left`. Rows with a few hundred bytes of headroom and a high key count are the ones a lookup table helps most. A v1 row can be well past 1232 bytes, and its size is the proof that the larger cap is in use.

To measure your own transaction, compile and encode it without sending it: pass the compiled transaction to `getTransactionEncoder` from `@solana/kit` (or call `getBase64EncodedWireTransaction`) and take the byte length of the result. Nothing has to land. The size of an unsent legacy or version 0 transaction is the same sum: one byte for the signature count, 64 bytes per signature, then the compiled message length.

## Shrink it before you split it

A transaction that fits stays atomic, so shrinking comes before splitting.

1. Remove accounts that appear twice or that an instruction does not need. Keys are 32 bytes each, so every account you drop returns 32 bytes.
2. Use a version 0 message with an address lookup table. A table entry is addressed by a one-byte index, so a 32-byte key becomes about one byte. The table has to be created and extended on chain first, and an address added to it can be used from the next slot.
3. Move bulk data out of the transaction. Write the payload into an account in several small transactions, then send one small instruction that tells the program to use it.
4. Choose compact instruction data: fixed-width integers, no padding, no strings you can replace with an index.

Lookup tables only reduce the bytes spent on account addresses. Signatures, the blockhash and instruction data keep their size, and signers cannot be moved into a table because their keys must be in the message to be verified.

## Splitting into several transactions

When the work still does not fit, split it. Each piece is a transaction of its own with its own signature, fee and blockhash, and the cluster treats them as unrelated.

Order is not guaranteed if you send them together. Send a dependent piece only after the one before it has been confirmed, and read that status with the [transaction status check](https://carbium.sh/library/howsolana/transaction-status-check). Pieces that do not depend on each other can go out in parallel.

Atomicity is gone. If piece three fails, pieces one and two stay on chain. Keep a small state account or a record on your side of which step ran, make each step safe to run twice, and resume from the first step that has no confirmation.

Splitting costs requests too. A `sendTransaction` call costs 20 cells without preflight and 70 with it on Carbium, so a four-piece job costs four sends plus the status reads between them.

## On Carbium

A default run in address mode makes one `getSignaturesForAddress` call at [50 cells](https://carbium.sh/docs#rpc) and five `getTransaction` calls at 50 cells each, 300 cells in all, which fits inside the 1,024-cell burst a rate class absorbs. For `getTransaction` the [sustained rate](https://carbium.sh/docs#limits) is 0.24 req/s on Free, 1.2 on Dev, 5 on Business and 25 on Pro. A Free key refills slowly, so runs close together use up the burst and the next one gets 429. Keep the sample small and pass signatures you already hold.

Mainnet carries v1 transactions. The file passes `maxSupportedTransactionVersion: 1`, and with the value absent or 0 `getTransaction` answers -32015 for a v1 transaction. The [version error](https://carbium.sh/library/howsolana/transaction-version-error-32015) entry covers that case on its own.

## Where it ends

The file reads transactions that already landed. It cannot tell you the size of a message you have not sent, and it does not build or sign anything.

It parses legacy and version 0 messages. It does not count the addresses a version 0 message pulls from lookup tables. For a v1 transaction it does not read the layout, so it prints the version and the byte count and `?` for left, sigs and keys. The byte count is still exact, because it is the length of what the node returns.

The address mode reads `getSignaturesForAddress`, which on Carbium reaches back 30 days at most from its own address index. Its pages can list a signature that `getTransaction` then answers with `null`, because the index reaches below the validator's ledger floor. The file prints `not returned by the node (older than its ledger)` for those and moves on.

It does not choose which accounts to drop or where to cut a job in two. That depends on your program, and the measurement only tells you how much room you have.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| A row reads `not returned by the node (older than its ledger)` for a signature the address mode listed. | The signature is older than the ledger the node holds. Address pages reach back further than getTransaction does. Test on the newest signatures, or pass signatures you saved recently. |
| Error -32015 on a signature. | The transaction is v1 and the call left out `maxSupportedTransactionVersion`. Keep `maxSupportedTransactionVersion: 1` in the config object. |
| HTTP 429 on several rows at once. | A Free key sustains 0.24 getTransaction calls a second, so runs close together use up the burst. Pass fewer signatures, or run again after the retry-after seconds the response names. |
| Your own transaction fails to build with a too-large error before it is sent. | The compiled size is over 1232 bytes. Measure what each account costs, drop duplicates, add a lookup table, then split if it still does not fit. |
| A lookup table address is rejected right after you extend the table. | The new entry is usable from the next slot. Wait for one slot to pass, then compile the message again. |
| `keys` shows `?` on a row. | The row is a v1 transaction or a layout the file does not parse. The `bytes` column is still the real length, which you compare with the cap of that version. |

## Questions

### Do the 64-byte signatures count toward 1232?

Yes. The limit applies to the whole serialized transaction, signatures included. A transaction with three signers spends 192 bytes before the message starts.

### Does a lookup table raise the limit?

No. The cap stays 1232 bytes for legacy and version 0 messages. A table shrinks the bytes spent on account addresses so more instructions fit under it.

### Can I send the pieces of a split job in one go?

Only the ones that do not depend on each other. Send a dependent piece after the previous one is confirmed, because arrival order at the leader is not guaranteed.

### Do I need a private key to run the checker?

No. It reads landed transactions by signature, which are public. The Carbium key only identifies your account to the RPC.

## Related

- [Transaction version error -32015](https://carbium.sh/library/howsolana/transaction-version-error-32015) (How to use Solana, HS0012)
- [Transaction explainer](https://carbium.sh/library/blockchainideas/transaction-explainer) (Blockchain ideas, BI0003)
- [carbium.sh/docs#rpc](https://carbium.sh/docs#rpc)
- [carbium.sh/docs#limits](https://carbium.sh/docs#limits)
- [carbium.sh/docs#auth](https://carbium.sh/docs#auth)
