How a cleanup works
Scan, quote, rounds, approvals, stamps and submit, and what each answer means.
A cleanup turns a selection of a wallet's assets into transactions that close or burn them and return their rent. The wallet signs every transaction, and the API co-signs and sends it, so the API checks everything that lands.
Scan
GET /v1/wallets/{address}/assets lists every asset the wallet holds. Each asset has an id you select it by, its kind (empty_account, token, nft, cnft, zk_compressed_token, or one of the creator and DeFi leftovers beyond token accounts), and its actions: everything that can be done with it, with what each returns (reclaimLamports), costs (feeLamports, with each charge in fees) and leaves in the wallet (netLamports). defaultAction is what the Burn & Claim app would do with it, and blockedReason says why an asset can't be acted on (frozen, unsupported).
| Action | What it does |
|---|---|
close | Closes an account and returns everything it holds |
burn | Burns a token's balance or an NFT, then closes its accounts. A burn names the exact amount the scan saw (expectedAmount), or it reverts |
withdraw_excess | Gives back a kept account's extra SOL, the lamports above its current rent-exempt minimum, and keeps the account open with its tokens. See How extra SOL works |
resize | Shrinks a legacy-sized NFT's metadata and master edition to today's sizes, and keeps the NFT |
zk_compress, zk_decompress | Moves a token between an ordinary account and ZK compression |
zk_compress is offered on SPL tokens, and on Token-2022 tokens whose mint carries only extensions Light's token pools take: metadata and group pointers, token metadata, groups and their members, interest-bearing and confidential transfers. A Token-2022 mint with a transfer fee, transfer hook, permanent delegate, default account state, close authority or pause, and an account with CPI Guard on, can be burned but not compressed. The first compression of a mint creates its token pool, and the pool's rent comes out of what the token account returns.
A zk_compressed_token holds no rent, so its two actions return nothing and each costs a fixed fee from the wallet: burn burns its whole balance (and lowers the mint's supply), and zk_decompress moves it into the wallet's own token account for the mint. When the wallet has no such account, the decompression creates it first, and the action's depositLamports says the rent the wallet puts into it: not a fee, since the wallet keeps that account, and closing it later returns the rent. Each spend carries a ZK validity proof read when it's quoted and built; if the network moves on before it's sent, submit answers simulation_failed without sending it, and preparing the items again reads a fresh proof.
Quote
POST /v1/transactions/quote prices a selection against the chain as it is now: each line with its charges, the totals, how many transactions it takes and how many wallet approvals (approvals). Items that can't be built are in skipped, with a reason. A quote builds nothing: it's what to show before the person agrees.
Each account gets the one action that fits it now. A withdraw from an account that held tokens at the scan and is empty now becomes a close, which returns everything; a close of an account that holds tokens again becomes a withdraw, which still works where the close would fail. Such a line says what was selected in switchedFrom. Keep sending the selection as it was: the API switches it the same way each time. Send a withdraw's expectedAmount (the scan's amount) so the API can tell an account emptied since the scan from one kept open on purpose.
A quote's figures move with rent, network fees and balances. Quote again before preparing a round when the quote is over 5 minutes old. To have the API check, send the quote's epoch as the first round's quotedEpoch, with its quotedAt: a quote over 5 minutes old, or from an earlier epoch, is refused with quote_stale before anything is built. When a selection of withdraws alone would return, after the fee, less than 3 times what sending it costs, the quote warns network_fees_high and the round answers nothing_to_build.
Rounds and approvals
POST /v1/transactions/rounds prepares one round: up to 50 transactions, packed as full as the network's limits allow, simulated, priced and stored with the fee schedule they were priced at. A round has no blockhash yet. Items that didn't fit come back in deferred: send them, as given, in the next round.
A round is split into approvals: groups of transaction indexes, each one wallet prompt, none bigger than maxTransactionsPerApproval (16 unless you ask for fewer, such as 1 for a wallet that signs one transaction at a time).
Stamp
POST /v1/transactions/rounds/{roundId}/stamp gives one approval's transactions a fresh blockhash, just before the wallet opens. It answers each transaction's unsigned bytes (base64), lastValidBlockHeight, and expiresInMs: about how long the blockhash lives. Sign and submit within it.
Stamp each approval only when its wallet prompt is about to open, never all of them at once: a blockhash lives about a minute. After staleAt, a round answers round_stale: prepare what hasn't landed in a new round.
Sign
The wallet signs each transaction, as the fee payer, and nothing else: it never sends them. The co-signer's signature slot stays empty for the API to fill.
Wallets may edit a transaction before they sign it, and the API accepts the edits they make on their own. The Seeker's Seed Vault Wallet raises a priority fee it finds too low, and Phantom may append Lighthouse assertions, which only read accounts and fail the transaction if one changed unexpectedly. Submit what the wallet returned, as it returned it. The API co-signs an edit only when every other instruction is byte for byte the one it built, in the same order, with the same fee payer, blockhash, signers and account access, and so the same charges. The wallet may change only the compute budget, meaning the compute-unit price, the compute-unit limit and the loaded-data limit, and it may append Lighthouse assertions that name no signer but the wallet. The priority fee it sets may be at most 0.001 SOL a transaction, and the wallet pays it: the transaction's record shows the network fee it actually paid. When the co-signer fronts the network fee, the wallet may add assertions but may not raise the fee. Any other change is refused (unrecognized_transaction), with a message that says what the wallet changed.
A wallet with too little SOL to pay a network fee can still start: Burn & Claim's co-signer pays the first transaction's fee and the wallet pays it back in that same transaction, out of what its closes and withdraws return. That round is the one transaction, and the rest comes back in deferred for the next round, which the wallet pays for itself. The co-signer is then that transaction's fee payer, so its signature, not the wallet's, is the transaction's id: use the signature submit answers. When the first transaction can't return enough to leave the wallet an open account, the round answers wallet_needs_sol instead.
Before it co-signs, the API checks that everything a transaction moves goes to the wallet, its quoted charges and that fee, and simulates one with withdraws: a withdraw that would give back less than quoted, because the account changed, is never sent.
Submit
POST /v1/transactions/submit takes an approval's transactions as the wallet signed them: byte for byte as stamped, or with only the wallet's own edits described above. For each one, the API checks it is exactly the one it built, co-signs it, sends it, waits for it to confirm and records it, and answers one result per transaction, in order:
status | What happened | What to do |
|---|---|---|
confirmed | It landed. transaction is its record, with every charge | Nothing |
failed_on_chain | It landed and failed: the runtime reverted everything in it, and the wallet paid the network fee | Show it; scan again before trying its items |
retry | No answer yet, or another stamp of it can still land (in_flight) | Submit the same signed bytes again shortly |
not_landed | Nothing happened on chain | Stamp those transactions again |
rejected with blockhash_expired | Nothing happened on chain | Stamp those transactions again |
rejected with changed_since_quote | A withdraw would now give back less than quoted: nothing was sent | Quote again, then prepare those items |
rejected with sponsor_unavailable | Burn & Claim can't pay this wallet's first network fee now: nothing was sent | Send the wallet a little SOL, then prepare those items again |
rejected, any other code | Refused (such as simulation_failed) | Prepare those items in a new round |
Keep submitting a retry until about 15 seconds past the stamp's expiry. After that its outcome isn't known: look it up with GET /v1/transactions/{signature} before trying its items again, so nothing is signed twice. The SDK's reclaim does all of this for you.
Transaction versions
Send transactionVersions with the versions the wallet signs: its Wallet Standard supportedTransactionVersions, without legacy. With 1 in the list, the API builds version 1 transactions (up to 4,096 bytes, SIMD-0296), which pack far more items into each transaction and so take fewer approvals.
Telegram bot setup
Connect a Telegram group or channel to your org, choose how it hears about cleanups, use the bot's commands, and run your org's own bot.
How extra SOL works
Why accounts a wallet keeps hold extra SOL now that Solana lowered rent, and how Burn & Claim gives it back with nothing closed.