services
Get a key

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

Recipient account rent budget

A read-only Node script that prices the rent deposit for each payout recipient with no token account for the mint, counts those wallets from live data, and prints the total in lamports and SOL to budget.

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

01

Why a first payout costs more

An embedded wallet starts empty. A user opens it with an email or a passkey, and nothing exists on chain for it beyond the address. USDC lives in a token account, one for each wallet and mint, so a wallet that has never held USDC has no place to receive it. The first payout has to create that account before the transfer can land.

Creating the account means funding it with a rent-exempt deposit: a lamport balance large enough that the account is never charged rent. Whoever pays for the creating instruction puts the deposit up, and in a payout that is the sender. The cost of a run is the transfers plus one deposit for every recipient new to the mint. Pay a hundred returning wallets and the budget is the network fees. Pay a hundred first-timers and it grows by a hundred deposits.

A deposit for a classic token account is about 0.0015 SOL. Across a payroll of new hires or a batch of referral rewards that becomes a line item finance will ask about, and it is paid in SOL even when the payout itself is in USDC.

02

Reading the deposit live

The deposit depends on the size of the account in bytes, and the network sets the price per byte. Ask the chain with getMinimumBalanceForRentExemption and pass 165, the size of a classic SPL token account. The answer is in lamports, and a lamport is a billionth of a SOL. A figure copied into your code goes stale when the rate changes, so the script asks at every run.

A Token-2022 associated account is at least 170 bytes, because each one carries the ImmutableOwner extension, and a mint with account-side extensions needs more. The script prices 165 bytes, so its figure is exact for the classic Token program and a lower bound for Token-2022. For a Token-2022 payout mint, change the size after you read the mint's extensions. The rent-exempt minimum calculator walks through the sizes.

The call leaves commitment out, so @solana/kit 8.6.0 reads at confirmed, where the JSON-RPC server's own default is finalized. A budget needs a recent figure, and the rent rate does not move from one slot to the next.

03

Counting recipients who need an account

To know who needs an account, ask what each wallet already holds. getTokenAccountsByOwner with a mint filter returns every token account that owner has for that mint, as a list. An empty list means the wallet has none, and your payout has to create one. A wallet can own more than one token account for a mint, so read the length of the list, never a yes or no.

Answer for the payout mintWhat it meansAdded cost to the sender
Empty listThe wallet has never held the mintOne deposit
One accountReady to receiveNone
Two or moreReady, but check which account you pay intoNone

Your real recipient list comes from your own records. To run the budget on live data, the script samples one. It lists the newest signatures of the USDC mint with getSignaturesForAddress, fetches the first successful transaction that names token owners, and takes up to five owners from its token balances. Each of those wallets holds USDC right now, so the script asks about a second mint: USDT, standing in for whatever you pay out in. The wallets with no USDT account are the ones that would cost you a deposit.

That is one call to list signatures, one getTransaction for each transaction tried and one owner lookup per wallet. Both the signature page and the transaction fetch cost 50 cells each. The loop stops at the first transaction that yields owners, so it is usually one fetch. The signature page runs at 0.24 req/s on Free, 1.2 on Dev, 100 on Business and 500 on Pro.

Mainnet carries v1 transactions, so getTransaction takes maxSupportedTransactionVersion: 1 together with an encoding. Left out, or set to 0, it answers -32015 for a v1 transaction.

04

The script

It needs only a key in CARBIUM_KEY, and it signs and sends nothing.

main.ts
// UC0099 · Recipient account rent budget// https://carbium.sh/library/usecase/recipient-account-rent-budget// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Budget the rent deposit for payout recipients who hold no token account for the payout mint.import { address, createDefaultRpcTransport, createSolanaRpcFromTransport } 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 rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));const USDC = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");const PAYOUT_MINT = address("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"); // USDT stands in for your payout mintconst TOKEN_ACCOUNT_BYTES = 165n; // classic SPL token account; Token-2022 accounts are larger// Sample recipients: up to five owners from the newest USDC transaction that names any. kit reads at confirmed.const owners = new Set<string>();const sigs = await rpc.getSignaturesForAddress(USDC, { limit: 10 }).send()  .catch((e: unknown) => { console.error(`getSignaturesForAddress failed: ${e}`); return process.exit(1); });for (const s of sigs) {  if (s.err) continue;  const tx = await rpc.getTransaction(s.signature, { encoding: "jsonParsed", maxSupportedTransactionVersion: 1 }).send()    .catch((e: unknown) => { console.log(`getTransaction ${s.signature.slice(0, 8)} failed: ${e}`); return null; });  for (const b of tx?.meta?.postTokenBalances ?? []) {    if (b.mint === USDC && b.owner && owners.size < 5) owners.add(b.owner);  }  if (owners.size) { console.log(`sampled from ${s.signature}`); break; }}const list = [...owners];if (!list.length) { console.log("no owners found in the newest transactions"); process.exit(0); }const rent = await rpc.getMinimumBalanceForRentExemption(TOKEN_ACCOUNT_BYTES).send()  .catch((e: unknown) => { console.log(`rent read failed: ${e}`); return null; });const checks = await Promise.allSettled(list.map((o) =>  rpc.getTokenAccountsByOwner(address(o), { mint: PAYOUT_MINT }, { encoding: "base64" }).send()));const needs: string[] = [];checks.forEach((c, i) => {  if (c.status === "rejected") { console.log(`${list[i]}  check failed: ${c.reason}`); return; }  const held = c.value.value.length;  console.log(`${list[i]}  ${held ? `${held} token account(s)` : "no token account, needs one"}`);  if (!held) needs.push(list[i]);});if (rent === null) process.exit(1);const total = BigInt(needs.length) * rent;const sol = `${total / 1_000_000_000n}.${(total % 1_000_000_000n).toString().padStart(9, "0")}`;console.log(`deposit per account ${rent} lamports; ${needs.length} of ${list.length} wallets need one`);console.log(`budget ${total} lamports = ${sol} SOL`);

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts

Each lookup settles on its own. A failed owner check prints its error on that wallet's line and the rest still count. The output lists each wallet, then the deposit per account, how many wallets need one, and the total in lamports and SOL. Lamports stay in a bigint until the final print and the SOL figure comes from integer division, so a long list never picks up float error.

05

Where it ends

  • The deposit sits inside the new account. It is not a fee. The owner of the account can close it once it is empty and send the lamports wherever they choose, so a recipient who closes an unused account takes the deposit with them. The sender gets it back only when the sender controls the wallet.
  • A Token-2022 mint with account-side extensions makes each account larger than 170 bytes, and the script's total is then too low. Read the mint's extensions and set the size before you rely on the figure.
  • An owner can hold a token account for the mint that is not the associated one. The lookup counts it, yet a payout sent to the associated address still has to create that account. Compare addresses when your payout tool always pays the associated account.
  • The count is a read at one moment. A wallet can receive its first token between your read and your send, and an idempotent create instruction makes that harmless, so the budget is an upper bound for that wallet.
  • The sample owners come from a live transaction and can include program-controlled wallets, such as liquidity pools. They show the shape of the output and are no stand-in for your recipients.
  • The script builds no transfer and creates no account. The instructions, the signing and the batching live in your own software.

For the check that runs before a whole payout, see the bulk payout preflight check.

06

When it goes wrong

what goes wrongwhat to do
The budget is wrong by a fixed amount for every wallet.The deposit was copied into code or a spreadsheet and the rate has changed since. Read it with getMinimumBalanceForRentExemption for the account size at each run.
A wallet is counted as ready, and the payout still fails or creates an account.The wallet holds a token account for the mint that is not the associated one. Compare the account addresses the lookup returns with the address your payout tool pays into.
getTransaction answers -32015 while sampling owners.Mainnet carries v1 transactions. Pass maxSupportedTransactionVersion: 1 together with an encoding.
getTransaction answers null for a signature the list returned.The signature list comes from an address index that reaches below the validator's ledger floor, so an older listed signature can answer null. The script's loop already skips a null answer and tries the next signature, and it reads the newest signatures, which a node still holds.
Every call answers 401.The key was cut short, so the door does not know it. Attach the whole key in CARBIUM_KEY.
07

Questions

Who gets the rent deposit back?

The owner of the token account. Closing an empty account sends its lamports to a destination the owner picks, so the sender only recovers a deposit when it controls the wallet. Treat it as a cost of onboarding the recipient.

Does a returning recipient cost anything extra?

No. A wallet that already holds an account for the mint needs no new one, so the transfer carries only the network fee.

Why not hard-code the lamport figure?

The rent rate is a network setting and it can change. One call to getMinimumBalanceForRentExemption keeps the budget true, and a stale constant misprices every run until someone notices.

Does the figure change for Token-2022 mints?

Yes. A Token-2022 associated account starts at 170 bytes and grows with each account-side extension, so its deposit is higher than a classic account's. Set the byte size in the script after you read the mint.