Guides
Sweep lists
A sweep list is a set of sweeps that go in one transaction of their own: up to the chain’s batch size, tokens and hot wallets mixed. No other sweep joins the list’s transaction, and none of its items goes in another. When your gas wallet on the chain is free, the request sends the transaction itself and answers with its hash.
A list or single sweeps
Section titled “A list or single sweeps”Single sweeps, POST /v1/sweeps | A list, POST /v1/sweep-lists | |
|---|---|---|
| Transaction | The service gathers your due sweeps into batches of up to the chain’s batch size. | One transaction of its own, whatever its size. |
| Hash | In transaction.sent, once the batch is sent. | In the response, when the gas wallet is free; otherwise in transaction.sent. |
| Fits | A steady flow of deposits: the cheapest per address. | Sweeps you need sent together and at once, with the hash in the response. |
The request
Section titled “The request”Each item is a sweep as in POST /v1/sweeps, without chain_id, and its external_id is required. A list has 1
to the chain’s batch size items: 50 on Ethereum and 200 on BSC, the same on their testnets. The body is up to
256 KiB.
{ "chain_id": 97, "wait": 10, "items": [ { "external_id": "dep-91a2", "hot_wallet": "0x2Cd50979a8A33e8CA37DA85F8517fb148a67b769", "account": "0x2c7536E3605D9C16a7a3D7b1898e529396a65c23", "token": "USDT" }, { "external_id": "dep-91a3", "hot_wallet": "0x589AdAfeCeb2CDD89fEFC9c37818511239Ed01ce", "account": "0x7f1D2c3B4a5E6d7C8b9A0f1e2D3c4B5a6978e0F1", "token": "native" } ]}The response is 202 Accepted with the list. Here the gas wallet was free: the list is sent, with its
transaction. The second address held nothing, and its item was rejected before sending:
{ "id": "4f0c2a7e-1b3d-4e5f-8a6b-9c0d1e2f3a4b", "chain_id": 97, "status": "sent", "transaction": { "id": 48517, "chain_id": 97, "kind": "sweep", "status": "pending", "hash": "0x5d2e8b0f6a4f1e9d3c7b2a1908f7e6d5c4b3a291807f6e5d4c3b2a1908f7e6d5", "sweeps": { "total": 1, "processing": 1, "swept": 0, "failed": 0, "requeued": 0 }, "list_id": "4f0c2a7e-1b3d-4e5f-8a6b-9c0d1e2f3a4b", … }, "items": [ { "id": "9a1e5c3b-2d4f-4a60-8b17-6c5d4e3f2a10", "external_id": "dep-91a2", "status": "processing" }, { "id": "77b0d2e4-6f81-4c3a-9d25-1e0f2a3b4c5d", "external_id": "dep-91a3", "status": "rejected", "reason": "nothing_to_sweep" } ], "created_at": "2026-10-27T09:14:01Z"}items are in the order of the request, in short: id, external_id, status and reason. The whole sweeps are
in GET /v1/sweeps?list_id=, the list as it is now in GET /v1/sweep-lists/{id}.
wait and the timeout
Section titled “wait and the timeout”wait is how many seconds the request may wait for the list to be sent: 0 to 55, 10 if you leave it out; 0
answers at once. Portuna may wait less on a chain. The answer comes within wait of the checks of the request:
set your HTTP client’s timeout to 60 seconds. The status of the list says how far it went:
status | What it means | The hash |
|---|---|---|
sent | It rides its transaction; items are processing, or rejected with a reason. | In transaction.hash. |
done | Every item has its outcome. transaction is the last one the list rode; there is none only when every item was rejected before sending. | In transaction.hash, if there is one. |
queued | It waits its turn, for example: you asked for wait 0, your gas wallet has a transaction in flight, something of yours is due before the list, the chain’s gas price is too high right now, or the service is already busy with your gas wallet’s work. | In transaction.sent, once it is sent. |
processing | It is being sent: wait ran out first, or the service was already working on your gas wallet’s queue and took the list there, which can come at once. The send goes on. | In transaction.sent, or in GET /v1/sweep-lists/{id}. |
Keep the transaction’s id: a replacement at a higher gas price changes its hash, not its id. The hash in the
answer is the version signed and recorded: the network may get it moments later, or only when it is rebroadcast;
transaction.sent and transaction.mined confirm it.
A client that hangs up before the answer repeats the request as it was: if the list was created, the repeat returns it with its transaction; if the request was cut off during its checks, the repeat creates it.
Order and checks
Section titled “Order and checks”- Order. A list waits its turn on the chain: after the sweeps you requested before it, before those you request after it. Lists go in the order you asked for them.
- Checks before sending. Each item is checked as a sweep is. One that fails, for example with
nothing_to_sweeporstale_authorization, is rejected at once, with its ownsweep.rejected, and is not checked again. The others go together. When every item is rejected, the list isdonewithout a transaction. - Revert or drop. A list whose transaction reverts or is dropped goes back to the queue whole and goes again in
a transaction of its own, its items checked again. An item whose attempts ran out is
failed.
Retries and conflicts
Section titled “Retries and conflicts”Every item needs an external_id, your own id for the sweep: it makes the request safe to repeat.
- A repeat has the same
chain_idand the same set ofexternal_id, in any order. It creates nothing, sends nothing and answers200 OKwith the list as it is now; the SDKs return it withcreated: false. A repeat is answered before the other checks: it gets its list even if lists were turned off on the chain since, or itswaitis not valid. The rate limit counts repeats too. The items’ bodies are not compared, as for a single sweep. - A partial overlap: some
external_idbelong to other sweeps, single ones or another list’s, or the same ids come on another chain or with other items. The answer is409 external_id_conflict, and nothing is created.details.itemsnames each of them: itsindexin the request,external_id, thesweep_idandlist_idthat have it, and itsstatus.
{ "error": { "code": "external_id_conflict", "message": "…", "details": { "items": [ { "index": 2, "external_id": "dep-91a4", "sweep_id": "5f2a9c7e-0d14-4b86-a3f9-7c1e2b8d4a50", "list_id": null, "status": "queued" }] } } }What to do: if they are your earlier sweeps of the same deposits, leave those items out and send the rest as a new
list. If the earlier ones ended rejected or failed and you want to try again, give the items new external_id.
Never use one external_id for different sweeps.
Refusals
Section titled “Refusals”A request with any invalid item is refused whole, and nothing is created:
422 invalid_items:details.itemshas each invalid item’sindex,codeandmessage, with the codes ofPOST /v1/sweeps, andduplicate_external_idfor an id that comes twice in the list. When every invalid item’s problem ishot_wallet_not_active, the status is409: try again once the delegate is deployed.422 invalid_items_count: no items, or more than the chain’s batch size,details.max.422 invalid_wait:waitis not a whole number from 0 to 55.404 not_found: lists are not available on this chain.
A list too heavy for one transaction
Section titled “A list too heavy for one transaction”A transaction may use at most 16,777,216 gas. The service estimates each list’s gas when it is asked for, and a list
above that gets 422 gas_limit_exceeded. details.max_items is how many of its first items fit: send them, and the
rest as another list.
{ "error": { "code": "gas_limit_exceeded", "message": "…", "details": { "estimated_gas": 17010400, "max_gas": 16777216, "max_items": 49 } } }How many items fit depends on the items. Of the base tokens, first sweeps of addresses that held only tokens weigh
the most: a list of 50 of them on Sepolia is close to the limit. A token of your own counts its whole item limit and
a reserve, about 600,000 gas an item, until its transfer is measured: on BSC about 24 such items fit in a list.
Whatever the list, details.max_items says where to split it.
Limits
Section titled “Limits”- Open lists: up to 10 of yours per chain, queued or on their way. The 11th gets
429 too_many_lists; ask again after the seconds ofRetry-After, about the time one transaction takes to be confirmed. - Requests: 20 in a row, then one every 2 seconds, on your account. Beyond that,
429 rate_limitedwithRetry-After.
Following a list
Section titled “Following a list”GET /v1/sweep-lists/{id}: the list and its items as they are now.GET /v1/sweeps?list_id=: its sweeps in full.GET /v1/transactions?list_id=: every transaction it rode, those that reverted or were dropped included.- Webhooks: the transaction events of a list carry its
list_id.
In the SDKs
Section titled “In the SDKs”client := portuna.NewClient(os.Getenv("PORTUNA_API_URL"), os.Getenv("PORTUNA_API_KEY"))// A list's request waits up to its wait for the transaction: give it 60 seconds.client.HTTPClient = &http.Client{Timeout: 60 * time.Second}items := make([]portuna.SweepListItemRequest, 0, len(deposits))for _, d := range deposits { items = append(items, portuna.SweepListItemRequest{ ExternalID: d.id, // required; repeating the request with the same ids returns this same list HotWallet: hotWallet, Account: d.account, Token: "USDT", // the whole balance: no Amount })}wait := 10list, created, err := client.CreateSweepList(ctx, portuna.SweepListRequest{ChainID: bscTestnet, Wait: &wait, Items: items})var apiErr *portuna.Errorswitch {case err == nil:case !errors.As(err, &apiErr): log.Fatal(err) // a network error or a timeout: repeat the request as it iscase apiErr.Code == "gas_limit_exceeded": // Too heavy for one transaction: its first max_items fit. Send them, and the rest as another list. maxItems, _ := apiErr.Details["max_items"].(float64) log.Fatalf("split the list after %d items", int(maxItems))case apiErr.Code == "external_id_conflict": // Some external ids belong to other sweeps, named in details.items: leave out those that are your earlier // sweeps of the same deposits and send the rest as a new list. log.Fatalf("taken: %v", apiErr.Details["items"])case apiErr.Code == "too_many_lists" || apiErr.Code == portuna.CodeRateLimited: // Ask again after the response's Retry-After. log.Fatalf("ask again in %s", apiErr.RetryAfter)default: log.Fatal(err) // fix the request: see Errors and retries}if !created { fmt.Println("a repeat: the list as it is now, nothing sent again")}switch {case list.Transaction != nil: // sent: the transaction it rides; done: every item has its outcome, and this is the last one it rode. Keep // the transaction's ID: a replacement at a higher fee changes its Hash. fmt.Println(list.Status, list.Transaction.ID, list.Transaction.Hash)case list.Status == portuna.ListDone: fmt.Println("every item was rejected before sending")default: // queued or processing: the transaction comes in transaction.sent, with this list's list_id. fmt.Println("on its way:", list.ID)}for _, it := range list.Items { if it.Status == portuna.SweepRejected { // Its external id is used up: to sweep the address again, use a new one. fmt.Println(it.ExternalID, "rejected:", it.Reason) }}const request: SweepListRequest = { chain_id: chainId, wait: 10, items: deposits.map((d) => ({ external_id: d.id, // required; repeating the request with the same ids returns this same list hot_wallet: hotWallet, account: d.account, token: 'USDT', // the whole balance: no amount })),}// The request waits up to its wait for the transaction: give it 60 seconds.const result = await client.createSweepList(request, { signal: AbortSignal.timeout(60_000) }).catch(refused)if (result) { const { list, created } = result if (!created) console.log('a repeat: the list as it is now, nothing sent again') if (list.transaction) { // sent: the transaction it rides; done: every item has its outcome, and this is the last one it rode. Keep the // transaction's id: a replacement at a higher fee changes its hash. console.log(list.status, list.transaction.id, list.transaction.hash) } else if (list.status === 'done') { console.log('every item was rejected before sending') } else { // queued or processing: the transaction comes in transaction.sent, with this list's list_id. console.log('on its way:', list.id) } for (const item of list.items) { // Its external_id is used up: to sweep the address again, use a new one. if (item.status === 'rejected') console.log(item.external_id, 'rejected:', item.reason) }}/** What to do when the list is refused; a network error or a timeout: repeat the request as it is. */function refused(err: unknown): undefined { if (!(err instanceof ApiError)) throw err if (err.code === 'gas_limit_exceeded') { // Too heavy for one transaction: its first max_items fit. Send them, and the rest as another list. console.log('split the list after', err.details?.max_items, 'items') } else if (err.code === 'external_id_conflict') { // Some external ids belong to other sweeps, named in details.items: leave out those that are your earlier sweeps // of the same deposits and send the rest as a new list. console.log('taken:', err.details?.items) } else if (err.code === 'too_many_lists' || err.code === 'rate_limited') { // Ask again after the response's Retry-After. console.log(`ask again in ${err.retryAfter ?? 60} seconds`) } else { throw err } return undefined}