Bulk payout preflight check
A read-only Node check for sending the same SPL token amount to many wallets with one memo. It finds missing and frozen token accounts, duplicate addresses and a short sender balance before you sign anything.
What a bulk payout is
No single Solana call sends the same amount of an SPL token to many addresses with a memo, because the chain has no such instruction. A payout is one transaction, or several, holding one transferChecked instruction per recipient and one instruction for the Memo program that carries your text. A transaction is capped at 1232 bytes, so a long list splits into batches, and each batch has its own signature.
Open-source airdrop scripts do the packing, and you can write your own in a few dozen lines with @solana/kit. Whichever one builds the transactions, the failures show up before anything is sent: a recipient with no token account for the mint, a frozen account, a sender that holds less than the total, a duplicate address, a memo that is too long. Reads reveal every one of them. The script below is that read-only check. It signs and sends nothing.
- Reads the mint to learn its token program and decimals.
- Derives each recipient's associated token account and reads all of them in one call.
- Compares the sender's balance with the amount times the number of recipients.
- Flags duplicates, missing accounts, frozen accounts, accounts with extensions and the rent the new accounts will need.
- Prints the memo and its size in bytes.
Run the check
The script takes a mint, an amount in base units, the sender's wallet and up to 99 recipient wallets. The memo text comes from PAYOUT_MEMO. It reads the mint first, because the mint's owner decides which token program derives the associated token accounts: the classic Token program or Token-2022. It sizes the rent read to match: 165 bytes for a classic token account and 170 for a Token-2022 associated account. 170 bytes is the smallest Token-2022 associated account. A mint with account-side extensions, such as a transfer fee, needs more, so the printed rent is a lower bound for those mints. Then one getMultipleAccounts call reads the sender's account and every recipient's. That call takes up to 300 pubkeys on Pro, and below Pro the 1024-cell burst caps it at 100, so the script keeps to 100 pubkeys on every plan and caps recipients at 99.
// UC0029 · Bulk payout preflight check// https://carbium.sh/library/usecase/bulk-payout-preflight-check// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only preflight for a bulk payout: the same token amount to many wallets, with one memo.import { address, createDefaultRpcTransport, createSolanaRpcFromTransport, getAddressEncoder, getProgramDerivedAddress, isAddress, type Address } 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 [mintArg, amountArg, senderArg, ...recipients] = process.argv.slice(2);const memo = process.env.PAYOUT_MEMO ?? "";if (!amountArg || !/^[0-9]+$/.test(amountArg) || recipients.length < 1 || recipients.length > 99 || ![mintArg, senderArg, ...recipients].every((a) => isAddress(a))) { console.error("Usage: PAYOUT_MEMO=<text> node main.ts <mint> <amount in base units> <sender wallet> <recipient> [<recipient> ...] (1 to 99 recipients)"); process.exit(1);}const TOKEN = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";const TOKEN_2022 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";const ATA_PROGRAM = address("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");const amount = BigInt(amountArg);const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));// The mint tells us the token program and decimals. kit reads at confirmed.const mintInfo = await rpc.getAccountInfo(address(mintArg), { encoding: "base64" }).send() .then((r) => r.value, (e: unknown) => { console.error(`mint read failed: ${e}`); return null; });if (!mintInfo || (mintInfo.owner !== TOKEN && mintInfo.owner !== TOKEN_2022)) { console.error(`${mintArg} is not a token mint`); process.exit(1);}// 165 bytes is a classic token account; 170 is the smallest Token-2022 associated account (ImmutableOwner), and account-side extensions such as a transfer fee need more, so the rent is a lower bound there.const rent = await rpc.getMinimumBalanceForRentExemption(mintInfo.owner === TOKEN_2022 ? 170n : 165n).send() .catch((e: unknown) => { console.log(`rent read failed: ${e}`); return null; });const decimals = Buffer.from(mintInfo.data[0], "base64")[44];const unit = 10n ** BigInt(decimals);const fmt = (n: bigint) => (decimals ? `${n / unit}.${(n % unit).toString().padStart(decimals, "0")}` : `${n}`);const encoder = getAddressEncoder();const ata = async (owner: string): Promise<Address> => (await getProgramDerivedAddress({ programAddress: ATA_PROGRAM, seeds: [encoder.encode(address(owner)), encoder.encode(mintInfo.owner), encoder.encode(address(mintArg))],}))[0];const wallets = [senderArg, ...recipients];const accounts = await Promise.all(wallets.map(ata));const { value } = await rpc.getMultipleAccounts(accounts, { encoding: "base64" }).send() .catch((e: unknown) => { console.error(`getMultipleAccounts failed: ${e}`); return process.exit(1); });const total = amount * BigInt(recipients.length);console.log(`${recipients.length} recipients, ${fmt(amount)} each, total ${fmt(total)} (decimals ${decimals})`);console.log(`memo "${memo}" is ${Buffer.byteLength(memo)} bytes`);if (new Set(recipients).size !== recipients.length) console.log("WARNING: the recipient list has duplicates");const sender = value[0] ? Buffer.from(value[0].data[0], "base64") : null;const held = sender && sender.length >= 165 ? sender.readBigUInt64LE(64) : 0n;console.log(`sender holds ${fmt(held)}, ${held >= total ? "enough" : `short by ${fmt(total - held)}`}`);let missing = 0, frozen = 0, extended = 0;recipients.forEach((w, i) => { const acc = value[i + 1]; if (!acc) { missing++; console.log(`${w} no token account yet, the payer creates it`); return; } const d = Buffer.from(acc.data[0], "base64"); if (d.length < 165) { console.log(`${w} ${d.length} bytes, not a token account, read by hand`); return; } if (d[108] === 2) { frozen++; console.log(`${w} FROZEN, a transfer in will fail`); return; } if (d.length > 165) extended++; console.log(`${w} ready${d.length > 165 ? `, ${d.length} bytes: extensions, not decoded here` : ""}`);});console.log(`missing ${missing}, frozen ${frozen}, with extensions ${extended}`);if (rent !== null) console.log(`rent for new accounts: ${BigInt(missing) * rent} lamports`);
run: CARBIUM_KEY=$CARBIUM_KEY PAYOUT_MEMO=run-2026-11-0042:b1 node main.ts <mint> <amount in base units> <sender wallet> <recipient wallet> <recipient wallet>
Amounts stay in a bigint of base units, and the decimals come from byte 44 of the mint, so the script converts only when it prints. The frozen state is byte 108 of a token account, and the script reads it on any account of 165 bytes or more. An account longer than 165 bytes carries extensions, such as the ImmutableOwner extension on every Token-2022 associated account. The script notes those separately and does not decode them. It leaves commitment out of each call, so @solana/kit 8.6.0 reads at confirmed, where the JSON-RPC server's own default is finalized. A check run ahead of a send only needs recent state, and you read the sender's balance again just before signing.
Each read is settled on its own. If the rent call fails, the script says so and carries on with the account read, and the recipient lines still print.
Carrying the memo
The Memo program takes UTF-8 text and writes it into the transaction's logs. A transaction can hold several memo instructions, so place one just ahead of the transfer it describes when each recipient needs its own text. One memo per transaction is simpler, and every recipient in that batch then shares it. To tell batches apart, put a run or invoice id in the text and give each batch its own suffix, for example run-2026-11-0042:b3.
Memo text counts against the 1232-byte limit, so the script prints the byte length, and each extra memo instruction adds its own bytes. A character outside ASCII takes several bytes. Keep the memo short: an id that points into your own ledger works better than a sentence of detail. The text is public on chain for good, so leave out names, emails and amounts owed.
Afterwards, getSignaturesForAddress returns a memo field with each signature, and it joins the memos of one transaction into a single string. getTransaction shows each memo in the log messages. Either lets a reconciliation match a transaction to your ledger by its memo text.
What the reads cost
Each call is charged a fixed number of cells.
| Call | Cells |
|---|---|
| getMultipleAccounts, per pubkey | 10 |
| getSignaturesForAddress | 50 |
| getTransaction | 50 |
| sendTransaction without preflight | 20 |
| sendTransaction with preflight | 70 |
The script makes three calls. The getMultipleAccounts call for 99 recipients and the sender is 100 pubkeys: 1000 cells, or 1001 when the request body passes 4 KiB. The mint's getAccountInfo read adds 10 more, and the rent read is one more small call. A longer list goes out as several calls of 100. The rate limits for this account-read class are 0.5 req/s on Free, 15 on Dev, 50 on Business and 400 on Pro.
A JSON-RPC request can be a batch of up to 100 calls with no added envelope. A class absorbs bursts of 1,024 cells or one second of its rate, whichever is larger.
Send, confirm, reconcile
Sending without preflight costs 20 cells and with preflight 70. Over 30 batches the difference is 1,500 cells. The check above already catches the usual failures of a standard transfer, so preflight on the send earns its cost mostly when several tools build the transactions.
A signature returned from a send means the node accepted the transaction. Check each batch with getSignatureStatuses and mark its recipients paid only when the status reports your target commitment with no error. A batch is atomic: every transfer in it lands or none does. Retry a failed batch whole, and only after you know the first one can no longer land because its blockhash expired.
For a push, signatureSubscribe on the WebSocket sends one confirmation and the subscription ends. It opens at 5 credits, then costs 20 credits per MiB sent. Your plan caps sockets and subscriptions per account, and Free carries 5 sockets. A large run can subscribe in waves or poll the statuses.
To reconcile, read the treasury's signatures and match each memo to a run id. The pages come from Carbium's own address index, which keeps up to 30 days. Store every signature yourself at the moment you send.
Where it ends
- Carbium builds and signs nothing here. The transfer and memo instructions, the batching and the signing live in your software.
- The script reads only the associated token account. A recipient who holds the token in another account shows as missing.
- Account state is read at one moment, and the issuer can freeze an account after it.
- The check shows that a token account exists. It cannot tell whether the wallet belongs to the right person, and a transfer cannot be recalled.
- A Token-2022 mint can add extensions: a transfer fee that leaves recipients with less than the amount, or a recipient account that requires a memo on incoming transfers. The script reads the frozen state on every account of 165 bytes or more and notes the ones that carry extensions, but it does not decode them.
- Signature history reaches back 30 days at most. An empty page past that marks the index's age limit, and the address may have older transactions. Older payouts live in your own ledger.
- Compliance checks on who you pay sit with you.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| The transaction is too large to send. | Each new token account adds an instruction and addresses on top of the transfer. Pack fewer recipients per batch, serialize the transaction and measure it before signing. The check counts missing accounts, so you can size batches that create accounts smaller. |
| A transfer fails for one recipient because the wallet has no token account for the mint. | Put an idempotent create-account instruction ahead of the transfer in the same transaction. The payer funds the rent, and the check prints the total for the missing accounts. For a Token-2022 mint with account-side extensions, such as a transfer fee, each new account needs more than 170 bytes, so that total is a lower bound. |
| The whole batch fails because the sender holds less than the batch total. | The check prints the shortfall for the whole list. Fund the sender first, and read its balance again right before signing. |
| One address appears twice and gets paid twice. | The check counts distinct recipients and warns on a repeat. Remove the duplicate from the list before you build any batch. |
| A retry pays a batch a second time. | Give every batch an id in your ledger, write its signature down before you send, and look the first signature up with getSignatureStatuses before you build a replacement. |
| getTransaction answers -32015 during reconciliation. | Mainnet carries v1 transactions. Pass maxSupportedTransactionVersion: 1 together with an encoding on getTransaction and getBlock. |
Questions
Can each recipient get its own memo?
Yes. A transaction can hold several memo instructions, each placed just ahead of its own transfer, and a Token-2022 required-memo account needs exactly that. Each memo adds bytes, so a batch holds fewer recipients, and getSignaturesForAddress joins the memos of one transaction into one string.
How many recipients fit in one transaction?
It depends on bytes, and the 1232-byte limit does not translate to a fixed count. Transfers to existing accounts take fewer bytes than ones that create the account first. Build a batch, serialize it, and size from the measured length.
Where do I read the memo afterwards?
The memo field on each getSignaturesForAddress entry carries it, and the log messages from getTransaction show it. Both read well for matching a transaction to a payout id.
Does the check work for a Token-2022 mint?
Yes. It reads the mint's owner, derives the associated accounts under that token program and checks the frozen state on each. An account longer than 165 bytes is noted as carrying extensions, because extensions can change what a transfer needs.