Concepts
How it works
The problem
Section titled “The problem”A deposit address holds your user’s tokens but no native coin to pay gas. A conventional sweep first sends the address some ETH or BNB for gas, then transfers the tokens from it: two transactions per deposit, a wallet to run the top-ups from, and leftover gas dust on every address.
The idea
Section titled “The idea”EIP-7702 lets a plain address (an EOA) run a contract’s code while keeping its own key. The address signs an authorization: “on this chain, run the code at this address”. After that, a transaction from anyone can call into the deposit address, and it runs the code it delegated to.
Portuna Sweep gives your hot wallets a small contract, a delegate, that holds a fixed set of them, one hot wallet or several, and can do exactly one thing: move the address’s tokens or native coin to a hot wallet of its set, the one each sweep specifies, when your own batcher contract asks. Each deposit address authorizes the delegate once. From then on one transaction from your gas wallet sweeps many deposit addresses at once, and none of them ever needs gas.
Your backend sends sweep requests to the Portuna Sweep API and gets webhooks back. Portuna Sweep sends one transaction from your gas wallet to your batcher, and the batcher calls sweep() on each deposit address. The addresses run the delegate's code, which each of them authorizes once with an EIP-7702 authorization your custody signs, and move the tokens or coin to your hot wallet.
The parts
Section titled “The parts”| Part | What it is |
|---|---|
| Deposit address | A plain EOA. Your custody holds its key, and the key signs only the authorization. After its first sweep the address carries a delegation: its code is 0xef0100 followed by the delegate’s address. It still receives tokens and native coin like any address. |
| Hot wallet | The address the funds go to. Any address you control. You register it once per chain, and it gets its own delegate. |
| Delegate | The SweepDelegate contract of a set of your hot wallets, from one to eight: the code your deposit addresses run. The set and your batcher are fixed in its bytecode, so it can send funds only to a hot wallet of the set, and only when your batcher calls it. No owner, no storage, no upgrades. |
| Batcher | Your SweepBatcher contract. Only your gas wallet can call it. It sweeps a list of deposit addresses in one transaction; an address that fails does not stop the others. |
| Factory | The shared SweepFactory contract that deploys batchers and delegates. It has no owner, and whoever calls it becomes the gas wallet of what it deploys, so nobody can deploy contracts in your name. |
| Gas wallet | An address Portuna creates for you, the same on every chain. You fund it with the chain’s native coin; it pays for deploying your contracts and for every batch, and your fees accrue on it. |
Your batcher and delegates are yours alone: no other partner’s transaction can call them. All three contracts are
created with CREATE2, so their addresses follow from their code. You can compute them yourself and check that the
code on chain is the open code: see Verifying the delegate.
One sweep, step by step
Section titled “One sweep, step by step”- You request a sweep:
POST /v1/sweepswith the deposit address, the token and, for the address’s first sweep, its signed authorization. The API checks the authorization at once: the right chain, a deployed delegate of yours that holds the sweep’s hot wallet, signed by the deposit address itself. - The service builds a batch. Sweeps that are queued by then go together, whatever hot wallets they go to, up to the chain’s batch size; the batch lists each hot wallet once for its sweeps. It reads the deposit addresses’ code and nonces, simulates the whole batch and leaves out anything that would fail.
- One transaction goes on chain, from your gas wallet to your batcher. A first sweep carries its authorization in the same transaction: the chain sets the delegate on the address, then the batcher calls it. Repeat sweeps need no authorization.
- After the confirmations, each sweep is
swept,failedorrejected, with its share of the gas and its fee. Your webhook gets the outcome. See Statuses, confirmations and reorgs.
Several hot wallets: delegates of sets
Section titled “Several hot wallets: delegates of sets”An address runs one delegate at a time. With a hot wallet’s own delegate, it sweeps into that hot wallet only. To
sweep one address into several hot wallets, choosing the hot wallet for each sweep, register them and create a
delegate for the set with POST /v1/delegates, up to eight hot wallets on a chain. Deposit addresses sign their
authorization for that delegate once; each sweep specifies its hot_wallet, and one batch can go to several of them.
The set is fixed: it is part of the delegate’s address, and the same set always gives the same delegate. To add a hot wallet later, create a delegate for the new set and have the addresses that should use it sign an authorization for it, sent with their next sweep; that sweep costs about as much as a first one. The old delegate keeps working for the addresses still on it. To make an address plain again, revoke the delegation.
Chains and tokens
Section titled “Chains and tokens”You can sweep a chain’s base tokens, its native coin and the tokens Portuna lists for it, which are on for every account until you turn one off, and any other ERC-20 you add on it by its contract address, after its check. The listed tokens:
| Chain | Chain ID | Native coin | Tokens |
|---|---|---|---|
| Ethereum | 1 | ETH | USDT 0xdAC17F958D2ee523a2206206994597C13D831ec7, USDC 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 |
| BSC | 56 | BNB | USDT 0x55d398326f99059fF775485246999027B3197955, USDC 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d |
| Sepolia | 11155111 | ETH | test USDT 0x3809a97a7a25C8bA577027c0AE2D81a09cdA1a2f |
| BSC testnet | 97 | BNB | test USDT 0x3809a97a7a25C8bA577027c0AE2D81a09cdA1a2f |
In a request, a listed token is its ticker (in any case) or its contract address, a token you added is its contract
address, and native is the chain’s coin. Any other token gets unknown_token, a token you turned off
token_disabled, and sweeps move only the requested token: airdrops and unknown tokens on an address are left alone.
Listing, checking, adding and turning off tokens, and how each amount is confirmed: Tokens.