---
id: BI0160
title: "Multisig proposal decoder"
url: https://carbium.sh/library/blockchainideas/multisig-proposal-decoder
collection: Blockchain ideas
category: DAO and treasury
revision: 1
updated: 2026-11-23
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# Multisig proposal decoder

A read-only script that pulls the newest transactions for the Squads v4 program and names each proposal and vault instruction by its Anchor tag. Five transactions and one signature list, and a tally you can read in under half a minute.

## Who hits this error

The message reached end of buffer unexpectedly comes from a Borsh decoder that tried to read more bytes than an account holds. People see it when they load a Squads account into a struct written for another layout, or when they pass an address that is not the account they meant. A treasury team that reads its own proposals usually meets it first in its own tooling.

Built for the team that wants a plain list of what the multisig program did recently, with each proposal instruction named. A signer team uses that list to see who opened or voted on a proposal. A treasury lead checks it before a vault transaction runs. The script reads instruction names from the transaction and never builds a struct from account bytes, so it cannot raise the buffer error itself.

## What the script reads

The script asks for the newest five signatures that touch the Squads v4 program, fetches each transaction, and keeps the top-level instructions whose program is Squads. Each instruction starts with an 8-byte tag. Anchor programs derive that tag from the instruction name, so the script computes the tag for five names and matches them against the data.

| Name | What it means | How the tag is made |
|---|---|---|
| `proposal_create` | a proposal is opened for a transaction index | first 8 bytes of sha256 of `global:proposal_create` |
| `proposal_vote` | a member approves or rejects a proposal | first 8 bytes of sha256 of `global:proposal_vote` |
| `proposal_activate` | a draft proposal goes live for voting | first 8 bytes of sha256 of `global:proposal_activate` |
| `vault_transaction_create` | a transaction is stored for the vault | first 8 bytes of sha256 of `global:vault_transaction_create` |
| `vault_transaction_execute` | a stored vault transaction runs | first 8 bytes of sha256 of `global:vault_transaction_execute` |

An instruction that matches none of the five prints as `other`. That is the expected label for the rest of the program's instructions, and the tally keeps it apart from the five names.

## The build

1. Read `CARBIUM_KEY` from the environment and exit when it is unset. The key travels in the `x-api-key` header, never in the URL.
2. Call getSignaturesForAddress on the program with a limit of 5. The call leaves commitment out, so @solana/kit sends confirmed.
3. For each signature, wait 4.2 seconds, then call getTransaction with the json encoding and `maxSupportedTransactionVersion: 1`, so a v1 transaction is answered.
4. Keep each top-level instruction whose program index points at Squads. Decode its data from base58 and compare the first 8 bytes with the five tags.
5. Print one line per match and a tally at the end. A failed call prints its message, and the run goes on to the next signature.

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

```ts
// BI0160 · Multisig proposal decoder
// https://carbium.sh/library/blockchainideas/multisig-proposal-decoder
// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.
// SPDX-License-Identifier: MIT

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

const apiKey = process.env.CARBIUM_KEY ?? "";
if (apiKey === "") {
  console.error("CARBIUM_KEY is not set; export it and run again.");
  process.exit(1);
}

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

// Squads v4: its newest transactions carry the proposal and vault instructions.
const SQUADS_V4 = address("SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf");
const WANTED = ["proposal_create", "proposal_vote", "proposal_activate", "vault_transaction_create", "vault_transaction_execute"];
// An Anchor instruction opens with the first 8 bytes of sha256("global:<name>").
const tagHex = (name: string): string => createHash("sha256").update(`global:${name}`).digest("hex").slice(0, 16);
const nameByTag = new Map(WANTED.map((name) => [tagHex(name), name]));
const base58 = getBase58Encoder();
const pause = (ms: number) => new Promise<void>((done) => setTimeout(done, ms));

const newest = await rpc.getSignaturesForAddress(SQUADS_V4, { limit: 5 }).send();
console.log(`${newest.length} newest signatures touch ${SQUADS_V4}`);
const counts: Record<string, number> = {};

for (const entry of newest) {
  await pause(4200);
  const sig = entry.signature;
  try {
    const txConfig = { commitment: "confirmed", encoding: "json", maxSupportedTransactionVersion: 1 } as const;
    const tx = await rpc.getTransaction(sig, txConfig).send();
    if (tx === null) {
      console.log(`${sig.slice(0, 8)} not served (null)`);
      continue;
    }
    const accounts = tx.transaction.message.accountKeys.map(String);
    for (const inst of tx.transaction.message.instructions) {
      if (accounts[inst.programIdIndex] !== SQUADS_V4) continue;
      const prefix = Array.from(base58.encode(inst.data)).slice(0, 8).map((b) => b.toString(16).padStart(2, "0")).join("");
      const label = nameByTag.get(prefix) ?? "other";
      counts[label] = (counts[label] ?? 0) + 1;
      console.log(`${sig.slice(0, 8)} ${label} accounts ${inst.accounts.length}`);
    }
  } catch (err) {
    console.error(`${sig.slice(0, 8)} failed:`, err instanceof Error ? err.message : err);
  }
}
console.log("tally", JSON.stringify(counts));
```

A run makes six calls, one signature list and five transactions. The signature call leaves commitment out, so @solana/kit sends confirmed, and the transaction calls ask for confirmed by name. The spacing keeps the five transaction calls from arriving together, and a null answer prints as not served before the run moves on.

## What a run costs

Each call is admitted at its own cell cost, as [the admission rule](https://carbium.sh/docs/rpc) sets out. getSignaturesForAddress costs 50 cells, and getTransaction costs 50 cells as well, so one run spends 300 cells across its six calls.

Rates differ by plan. On Free, getSignaturesForAddress is held to 0.24 calls a second, and the script makes one such call per run, so the limit does not come into play. The transaction calls are spaced by the script itself. A call over its rate waits once, and a call that cannot be served gets a 429 with a retry-after hint, which the failures section covers.

Credits meter RPC work as well, so a script that runs every few minutes adds up over a month. A one-off run is small. A scheduled one should be checked against the plan's monthly credits before it is set to repeat.

## Fixing the buffer error

If your own decoder fails, check the length before the read. Compare the account's data length with the size your struct needs, and confirm the account's owner is the Squads program. A short account means the layout you assumed is not the one on chain, or the address points at a different kind of account.

Name the instruction first. Once the tag says `proposal_create`, you know which account layout applies, and you can read the fields for that layout and no others. Take the layout from the program's published IDL or source for the version you target. A struct from another version of the program will not fit the bytes, and the decoder will run out of buffer at the first field that differs.

## Where it ends

- The script reads top-level instructions only. A Squads instruction called from another program sits in the inner instructions, and this script does not read them.
- It names instructions and does not read proposal account state. The approval count, the threshold and a proposal's status need an account read with that account's layout.
- Only the newest five signatures are read per run. A longer history needs a loop with a cursor, and each page is charged at 50 cells.
- getSignaturesForAddress pages come from an index that keeps 30 days at most. An empty page past that marks the index's age limit, and an older Squads transaction will not appear.
- A getTransaction call can answer null for a signature the index lists. The script prints that line as not served and moves on.
- The tag match assumes Anchor's naming rule for the five names. A future program version that renames one of them shows that instruction as `other`.

## When it goes wrong

| What goes wrong | What to do |
|---|---|
| Every instruction prints as other. | The program is right, and the five names are not the ones your version uses, or the program id is wrong. `other` is the correct label for any instruction outside the five, so check the names against the version you run. |
| The call answers 401 at the door (UNKNOWN_KEY). | Attach the whole key in the `x-api-key` header. A truncated key gets this answer, so copy it again from the dashboard. |
| A call answers 429 with a retry-after hint. | Wait the number of seconds in the hint and run again. The 4.2 second spacing is a floor, not a guarantee, and the signature rate on Free is shared with other calls on the same account. |
| getTransaction answers -32015. | The call must carry `maxSupportedTransactionVersion: 1`, which is what the code sends. Restore that field and retry; see [the version error](https://carbium.sh/library/howsolana/transaction-version-error-32015). |
| The run ends with an empty tally. | The five newest signatures may carry no top-level Squads instruction. Raise the limit, or watch the multisig address in place of the program so that only its own transactions are read. |
| Your own decoder still says reached end of buffer unexpectedly. | Read the account length before the struct, and match the struct to the program version that wrote the account. The steps are in the fix section. |

## Questions

### Why does my decoder say reached end of buffer unexpectedly?

The decoder read past the end of the account's data. The struct asks for more bytes than the account holds, usually because the account type or the program version is not the one you assumed. Check the owner and the length before you read.

### Does this show who approved a proposal?

Not directly. It shows that a proposal_vote instruction ran at the top level and how many accounts it used. The member and the vote are in the instruction's arguments and accounts, which this script does not read.

### Can I watch one multisig instead of the whole program?

Yes. Pass the multisig address to getSignaturesForAddress in place of the program and keep the Squads program test, so only that account's Squads instructions are counted. The cost per call stays the same.

### Will it run on the Free plan?

Yes for one run. It makes six calls at 50 cells each, and the signature call stays within the Free rate. A 429 is answered with a wait, as the failures section explains.

## Related

- [Transaction version error -32015](https://carbium.sh/library/howsolana/transaction-version-error-32015) (How to use Solana, HS0012)
- [Multisig approval watcher](https://carbium.sh/library/blockchainideas/multisig-approval-watcher) (Blockchain ideas, BI0059)
- [carbium.sh/docs/rpc](https://carbium.sh/docs/rpc)
- [carbium.sh/docs/auth](https://carbium.sh/docs/auth)
- [carbium.sh/docs/errors](https://carbium.sh/docs/errors)
- [carbium.sh/docs/limits](https://carbium.sh/docs/limits)
- [carbium.sh/docs/endpoints](https://carbium.sh/docs/endpoints)
