services
Get a key

library / Use cases / Payouts, payroll and remittance / UC0097

Failed payout reason codes

A Node script that reads the newest 100 signatures on the USDC mint, turns every failed status into a reason code, and prints a histogram with one sample signature per reason, plus the failing log line when you ask.

By Carbium · Payouts, payroll and remittance · UC0097 · updated 2026-11-22

01

Where the error sits in a status

A USDC transfer that fails with "Invalid account data for instruction" carries that sentence as the decoded form of a field in its status. Each entry from getSignaturesForAddress has an err field, null for a transaction that ran to the end and an object or string for one that failed. A failure inside an instruction looks like {"InstructionError": [0, "InvalidAccountData"]}: the position of the failing instruction, then the error. When the program defines the error itself, the second item is an object such as {"Custom": 1}.

Three levels cover every status. A null means success. A bare name or a one-key object names a failure of the whole transaction. The InstructionError key adds the instruction index and the error. In a payout transaction that packs several transfers, the index tells you which recipient failed. A failed transaction moves no tokens, and the sender still pays its fee, so retrying a failed payout before finding its cause pays that fee again on every attempt.

$The usual cause of invalid account data in a USDC transfer is a wallet address in the slot for a token account. A wallet holds SOL and has no token data. Its USDC sits in a separate token account, and the transfer instruction has to name that one.
02

The reason table

Reason codes group the statuses that payout staff meet most. The script prints each one in the form used in the first column, with custom numbers in hex, the way program logs write them.

ErrorLikely causeAction
InstructionError/InvalidAccountDataA wallet or mint address in a token account slot, or a token account nobody createdResolve the recipient's token account for the mint and create it ahead of the transfer when it is missing
InstructionError/IncorrectProgramIdAn account belongs to another program, such as a Token-2022 account sent to the original Token programRead the mint's owner and build the instruction for that program
InstructionError/Custom(0x1)Token program InsufficientFunds: the source token account holds less than the amount. The System program also uses 0x1, see the SOL row belowFund the source account, then resend
InstructionError/Custom(0x3)Token program MintMismatch: the two token accounts hold different mintsDerive the destination for the payout mint
InstructionError/Custom(0x4)Token program OwnerMismatch: the signer neither owns the source account nor holds a delegation on itSign with the owner of the source account
InstructionError/Custom(0x9)Token program UninitializedState: the account has room for token data and nobody initialized itUse a properly created token account
InstructionError/Custom(0x11)Token program AccountFrozen: the issuer froze the source or destination token accountHold the payout and ask the issuer
InstructionError/Custom(0x12)Token program MintDecimalsMismatch: the decimals in a transferChecked instruction differ from the mint'sRead the decimals from the mint and rebuild
InstructionError/MissingRequiredSignatureA required signer did not signAdd the signer to the transaction
InstructionError/Custom(0x1)System program ResultWithNegativeLamports: a native transfer asked for more SOL than the account holds. The Token program also uses 0x1, see the row aboveTop up the SOL balance
InsufficientFundsForRentThe transaction left an account below the rent minimumFund the account to the minimum or empty it completely
InstructionError/ComputationalBudgetExceededThe compute unit limit was too low for the instructionsRaise the limit, as in compute limit from simulation

InvalidAccountData comes first because it confuses people most. The destination of a USDC transfer has to be an initialized token account for the USDC mint. A wallet address fails because that account belongs to the system program and holds no token data. A mint address fails because a mint's data has another layout and length. An associated token account address that nobody created fails because nothing is stored there. In the third case, create the account with an idempotent instruction ahead of the transfer in the same transaction. In the other two, replace the address.

03

Whose custom code it is

A Custom number means something only with the program that raised it. Each program keeps its own list of errors and counts from its own start, so Custom(0x1) from the Token program is an empty balance, while the same number from a swap program or an escrow program names something else. The status in the signature list carries the number and never the program id.

The program id sits in the transaction's log messages, in a line like Program <id> failed: custom program error: 0x1. Read the id first, then look the number up in that program's own list. Token-2022 starts with the same early numbers as the original Token program, so a stablecoin on either one reads alike in the table. Programs written with Anchor number their own errors from 6000 (0x1770), so a number from 6000 up is the application program's own error and needs its published list, while 100 to 5999 are Anchor's framework errors.

That is why the script names a custom code only when the log line shows the Token program. Any other program's code stays under its number, labelled with the program id, and goes to whoever owns that integration.

04

Sorting a page of failures

The script reads the newest 100 signatures for an address. The default is the USDC mint, whose list holds only the transactions that name the mint: transferChecked calls, account creations and swaps. A plain Transfer lists the source account, the destination account and the authority, so it never appears there. For every payout of your own, pass your treasury token account or sender wallet as the first argument. Each non-null err becomes a reason code, and the output is a count per code with one sample signature, most frequent first. The word logs as the second argument fetches the top reason's sample with getTransaction and prints the failing log line.

main.ts
// UC0097 · Failed payout reason codes// https://carbium.sh/library/usecase/failed-payout-reason-codes// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Sorts the failed transactions among an address's newest signatures into reason codes.import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, isAddress, type Signature } 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 url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";const USDC = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";const TOKEN = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";const [target = USDC, mode] = process.argv.slice(2);if (!isAddress(target)) { console.error("Usage: node main.ts [address] [logs]"); process.exit(1); }// Names for the Token program's own custom codes. Another program's code 1 means something else.const TOKEN_ERRORS: Record<number, string> = { 1: "InsufficientFunds", 3: "MintMismatch", 4: "OwnerMismatch", 9: "UninitializedState", 17: "AccountFrozen", 18: "MintDecimalsMismatch" };// Turns the err field of a status into one short reason code.function reason(err: unknown): string {  if (typeof err === "string") return err;  const [name, body] = Object.entries(err as object)[0];  if (name !== "InstructionError") return name;  const inner = (body as [number, unknown])[1];  if (typeof inner === "string") return `InstructionError/${inner}`;  const [kind, value] = Object.entries(inner as object)[0];  return kind === "Custom" ? `InstructionError/Custom(0x${Number(value).toString(16)})` : `InstructionError/${kind}`;}const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));// No commitment is passed, so kit 8.6.0 reads at confirmed.const page = await rpc.getSignaturesForAddress(address(target), { limit: 100 }).send()  .catch((e: unknown) => { console.error(`getSignaturesForAddress failed: ${e}`); return process.exit(1); });const reasons = new Map<string, { count: number; sample: Signature }>();for (const s of page) {  if (s.err === null) continue;  const code = reason(s.err);  const seen = reasons.get(code);  if (seen) seen.count++; else reasons.set(code, { count: 1, sample: s.signature });}const failed = [...reasons.values()].reduce((n, r) => n + r.count, 0);console.log(`${target}: ${failed} failed of ${page.length} newest signatures`);const ranked = [...reasons].sort((a, b) => b[1].count - a[1].count);for (const [code, r] of ranked) console.log(`${String(r.count).padStart(4)}  ${code}  e.g. ${r.sample}`);if (ranked.length === 0) console.log("no failures in this page, pass a busier address or your own sender");if (mode === "logs" && ranked.length > 0) {  const [code, top] = ranked[0];  const tx = await rpc.getTransaction(top.sample, { encoding: "json", maxSupportedTransactionVersion: 1 }).send()    .catch((e: unknown) => { console.log(`getTransaction failed: ${e}`); return null; });  const line = tx?.meta?.logMessages?.find((l) => l.includes(" failed: "));  console.log(tx ? `${code} log: ${line ?? "no failing line in the logs"}` : "getTransaction answered null for that signature");  const hit = line?.match(/^Program (\w+) failed: custom program error: 0x([0-9a-f]+)/);  if (hit) console.log(hit[1] === TOKEN ? `Token program code: ${TOKEN_ERRORS[parseInt(hit[2], 16)] ?? "not in this table"}` : `program ${hit[1]} owns this code, left unclassified`);}

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v logs

getTransaction takes maxSupportedTransactionVersion: 1 together with an encoding. Mainnet carries v1 transactions, and without the setting the call answers -32015, uncharged, for a v1 transaction or a block holding one. The script sends no commitment, so @solana/kit 8.6.0 reads at confirmed. Each call costs 50 cells. A run makes one getSignaturesForAddress call and at most one getTransaction. The list call runs at 0.24 req/s on Free, 1.2 on Dev, 100 on Business and 500 on Pro, and the lookup runs at 0.24, 1.2, 5 and 25 req/s. A failed lookup is caught and printed after the histogram has already printed.

05

Handing reasons to staff

A reason code helps once it names the team that acts. Four queues cover the table above.

  • Fix the recipient: InvalidAccountData, IncorrectProgramId and a mint mismatch. Staff confirm the payout address, look up its associated token address for the right token program, and resend once the account exists.
  • Fix the sender: token balance, wrong owner, missing signature, a SOL shortfall (System program Custom(0x1)) and rent. Treasury tops up or changes the signer set.
  • Ask the issuer: a frozen account stays frozen until the issuer lifts it, so hold that payout and tell the recipient.
  • Send to engineering: compute budget errors and every program the table does not know.

Keep the sample signature next to each count. A support agent opens it in an explorer, sees the instruction index and knows which line of the run failed. Send recipient preflight catches the first queue before the send.

06

Where it ends

  • Only landed transactions have a status. A send that never reached a block has no signature entry, so expired and dropped sends need a separate check.
  • A hundred entries is one page. It shows the mix of causes on that page and says nothing about rates over a week.
  • The signature list reaches only as far as Carbium's address index, which keeps up to 30 days. An empty page past that marks the index's age limit, and the address may have older transactions.
  • A signature the list shows can still come back null from getTransaction when it is older than the node's ledger. The script prints that and keeps the reason from err.
  • A custom code from a program other than the Token program stays unclassified. Naming it takes that program's own error list, and the log line is the only place the program id appears.
  • The status says what failed and never who was at fault. A frozen account or a wrong address needs a person to decide.
07

When it goes wrong

what goes wrongwhat to do
getTransaction answers -32015 for a signature in the list.The transaction is v1. Pass maxSupportedTransactionVersion: 1 together with an encoding, as the script does.
getTransaction returns null for a signature the list shows.The signature is older than the node's ledger, and the address index reaches below it. Keep the reason from the err field and skip the log line.
The histogram shows no failures.A page of 100 can hold only successes on a quiet address. Pass your own sender or treasury token account, or page further back with the before option.
A custom code is labelled with the wrong name.Code numbers belong to one program each. Read the program id in the failing log line before looking the number up.
InvalidAccountData persists after the recipient's account was created.The instruction may still name the wallet, or the account was derived for the wrong token program. A Token-2022 mint needs the address derived under Token-2022.
08

Questions

What does Invalid account data for instruction mean on a USDC transfer?

An account in the instruction held data the token program could not read as a token account. The usual causes are a wallet address in the destination slot, a mint address there, or an associated token account that was never created.

Does a failed transfer cost anything?

The sender pays the transaction fee, and no tokens move. Retrying without a diagnosis pays the fee again each time.

Why is the code 17 in a status and 0x11 in the logs?

It is one number. The status holds it in decimal and program logs print it in hex. The script prints hex, so a code lines up with the log line.

Can I classify without calling getTransaction?

Named errors such as InvalidAccountData come straight from the status. A custom number needs the log line, because only the log names the program.