services
Get a key

library / Use cases / UC0004

Cross-border USDC payouts

A payout run to recipients in other countries: check every wallet can receive USDC before you send, confirm each transfer at the right commitment, and reconcile afterwards. Includes a read-only Node pre-flight that reads up to 100 wallets in one call.

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

01

What a payout run involves

A cross-border payout in USDC is a list of recipients, an amount for each and one treasury wallet that pays them. Settlement is a token transfer on Solana, so a run does not wait for banking hours in the recipient's country, and each payment is one transaction you can read back afterwards.

  1. Check that each recipient wallet can receive USDC.
  2. Build one transfer per recipient, creating the USDC account first where it is missing.
  3. Sign and send from your own signer.
  4. Confirm each signature at finalized.
  5. Reconcile the treasury's history against your own ledger.

Carbium covers the read and relay parts: account reads, sending a signed transaction, signature confirmation and address history. Signing stays in your software, and the pre-flight signs nothing. Converting local currency into USDC and back happens with the licensed partners you choose, outside the chain and outside Carbium.

02

Check every wallet before you send

USDC is held in a token account. The usual one is the associated token account, an address derived from the owner wallet, the token program and the USDC mint. A recipient who has never held USDC has no such account, and your transfer has to create it first. The payer funds that account with about 0.002 SOL of rent. A transfer built without the creation step fails for that recipient.

The issuer can also freeze a USDC account, and a transfer into a frozen account fails. A pre-flight finds both cases before any money moves.

The script takes up to 100 recipient wallets as arguments. It derives each associated USDC account with @solana/kit, reads them all in one getMultipleAccounts call and parses the 165-byte token account layout: the amount is a little-endian u64 at byte 64, and the state byte at 108 is 2 when the account is frozen. It prints one status line per recipient and a summary with the rent the new accounts will need. Requests go to the RPC endpoint at https://services.carbium.sh unless CARBIUM_RPC_URL says otherwise, with the key from CARBIUM_KEY.

main.ts
// UC0004 · Cross-border USDC payouts// https://carbium.sh/library/usecase/cross-border-usdc-payouts// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MIT// Read-only pre-flight for a USDC payout: can each recipient wallet receive USDC right now?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 wallets = process.argv.slice(2);if (wallets.length === 0 || wallets.length > 100 || !wallets.every((w) => isAddress(w))) {  console.error("Usage: node main.ts <recipient wallet> [<recipient wallet> ...] (1 to 100 valid addresses)");  process.exit(1);}const MINT = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); // USDC on mainnetconst TOKEN_PROGRAM = address("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");const ATA_PROGRAM = address("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");const USDC_UNIT = 1_000_000n; // 6 decimals: amounts stay integer base units until printedconst RENT_LAMPORTS = 2_039_280n; // rent-exempt minimum for a 165-byte token accountconst fmt = (n: bigint) => `${n / USDC_UNIT}.${(n % USDC_UNIT).toString().padStart(6, "0")}`;const encoder = getAddressEncoder();const usdcAccount = async (owner: string): Promise<Address> => {  const [pda] = await getProgramDerivedAddress({    programAddress: ATA_PROGRAM,    seeds: [encoder.encode(address(owner)), encoder.encode(TOKEN_PROGRAM), encoder.encode(MINT)],  });  return pda;};const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));const accounts = await Promise.all(wallets.map(usdcAccount));// kit would fill in confirmed here; a payout names finalized itself.const { context, value } = await rpc.getMultipleAccounts(accounts, { commitment: "finalized", encoding: "base64" }).send();console.log(`read ${accounts.length} USDC accounts at finalized, slot ${context.slot}`);let ready = 0, missing = 0, frozen = 0;value.forEach((acc, i) => {  if (!acc) { missing++; console.log(`${wallets[i]}  no USDC account yet, the payer creates it`); return; }  const data = Buffer.from(acc.data[0], "base64");  if (data.length !== 165) { console.log(`${wallets[i]}  not a 165-byte token account, check by hand`); return; }  if (data[108] === 2) { frozen++; console.log(`${wallets[i]}  FROZEN, a transfer in will fail`); return; }  ready++;  console.log(`${wallets[i]}  ready, holds ${fmt(data.readBigUInt64LE(64))} USDC`);});console.log(`ready ${ready}, missing ${missing}, frozen ${frozen}`);console.log(`rent for new accounts: ${BigInt(missing) * RENT_LAMPORTS} lamports`);

run: CARBIUM_KEY=$CARBIUM_KEY node main.ts <recipient wallet> <recipient wallet>

Amounts stay integer base units in a bigint, and USDC has 6 decimals, so the script converts only when it prints. The call names commitment: "finalized" itself, because a payout should say which level it reads at.

03

What the run costs in cells

Each call costs a fixed number of cells by method class, and request rates differ by class and plan. A payout run uses four classes.

CallCellsFree req/sDev req/sBusiness req/sPro req/s
getMultipleAccounts, per pubkey100.51550400
getSignaturesForAddress500.241.2100500
getTransaction500.241.2525
sendTransaction without preflight200.251.5525

getMultipleAccounts charges 10 cells per pubkey and takes up to 100 pubkeys below Pro, so the pre-flight for 100 recipients is one request of 1000 cells. Limits are per account, and an account's keys share one budget.

For a large run, split the wallet list into chunks and create the RPC client once at start-up, then reuse it for every chunk.

04

Send, confirm and reconcile

sendTransaction costs 20 cells without preflight and 70 with it. The 50-cell difference over 300 transfers is 15,000 cells, so decide per run. The pre-flight above already catches the common failures for a standard transfer, and preflight earns its cost when several tools build the transfers.

A returned signature means the transaction was submitted. Read each signature's status at finalized and flip the ledger row to paid on that answer alone.

For push confirmation, `signatureSubscribe` sends one confirmation for a signature and then the subscription ends. A subscription at that weight opens at 5 credits and then costs 20 credits per MiB sent. A refused one is free. Connection and subscription counts are capped per account by tier, and Free carries 5 sockets, so for a large run subscribe in waves or read the recipient's account again after sending.

To reconcile, read the treasury with getSignaturesForAddress at 50 cells and match each signature to a payout id in your ledger. Its pages come from Carbium's own address index, which keeps up to 30 days. Store every signature yourself as you send it. getTransaction costs 50 cells and returns the pre and post token balances for any one payment you need to prove.

05

Funding the treasury in USDC

If the treasury holds another token, convert the whole run's total in one swap before the first transfer. Quotes answer on the RPC endpoint as JSON-RPC with four methods, quote, swap, health and prices. The swap method returns one unsigned transaction for a quote, and your software signs and sends it.

A quote's platformFee is 5 bps (0.05%), an on-chain fee inside the transaction your software signs and sends. A key needs the QUOTE scope. Quote plans are per account: Free at $0 with 10 quotes/s, Starter at $7 with 50/s, Pro at $28 with 150/s and Elite at $104 with 500/s. A payout run needs a handful of quotes, so the Free rate covers it.

06

Where it ends

  • Compliance: KYC, sanctions screening and the rules for sending money across borders sit with you and your partners. Nothing here decides whether a payout is allowed.
  • A transfer is final. A wrong address cannot be recalled, and the pre-flight tells you that an account can receive USDC and has no way to tell you it belongs to the right person.
  • The script assumes the standard associated account. A recipient who holds USDC in some other token account shows as missing even though the funds exist.
  • The issuer can freeze an account at any time. The pre-flight reads the state at one moment.
  • The script is read-only. It builds no transfer, holds no key and sends nothing, so the create-account and transfer instructions are yours to write and sign.
  • History: getSignaturesForAddress reaches back 30 days at most, and an empty page past that is the index's age limit. Older payments live in your own ledger.
  • Eight methods are not served and answer -32601, among them getTokenLargestAccounts and getProgramAccountsV2. -32601 here means the method is not served: do not retry, use another method.
  • Fiat on and off ramps are not part of Carbium. Carbium serves chain reads, sends and quotes.
07

When it goes wrong

what goes wrongwhat to do
A transfer fails for one recipient because the wallet holds no USDC account.Run the pre-flight first. For each missing account, put a create-account instruction in its idempotent form ahead of the transfer in the same transaction, and budget about 0.002 SOL of rent per account, paid by the payer.
A recipient's USDC account is frozen and the transfer into it fails.Only the issuer can unfreeze it. Ask the recipient for another account they control, and hold that payout out of the batch until you have it.
The run reports payments as sent that never landed.Treat a returned signature as submitted. Mark a payment paid after finalized confirmation, and before building a second transfer for the same payout confirm the first can no longer land.
The same recipient is paid twice after a retry.Key every payout by an id in your ledger, write the signature down before you send, and look the first signature up before building a replacement transfer.
A large pre-flight returns 429.Each pubkey costs 10 cells. Split the wallet list into chunks, wait the retry-after time and retry once, and reuse one client for every chunk.
08

Questions

How many recipients fit in one pre-flight read?

getMultipleAccounts takes up to 300 pubkeys on Pro and 100 below it, at 10 cells per pubkey, so a 100-wallet call costs 1000 cells. Send larger lists as several calls.

Which commitment should a payout wait for?

Wait for finalized before you mark a payment paid, and name finalized in each call that reads the chain.

Can I look up a payment from last quarter?

getSignaturesForAddress reaches back 30 days at most. Keep your own ledger with a signature for every payout, and use that for anything older.

Does the pre-flight work for a recipient that is a program-controlled wallet?

Yes. The associated account is derived from the owner address, and the derivation accepts any address, whether or not it has a private key.

Does Carbium convert USDC into local currency?

No. Off-ramps run through the licensed partners you pick. Carbium serves the chain reads, sends and quotes around them.