← Blog

The Solana Deeds #2: Who gets a cut of the dodgems?

Why a Solana Token-2022 transfer sets its fee aside at payment, explained with a make-believe Ekka and verified on devnet.

Nissan Dookeran5 min readSolanaCoding AgentsAgent Workflows

Picture a make-believe version of the Ekka, Queensland's big show. You buy a strip of ride tickets. The same tickets work at the dodgems and the Ferris wheel. Every time a ride operator takes a ticket, the grounds manager is owed a 2.5% cut.

Now picture the dodgems queue if the manager had to come over and collect that cut before the operator could let anyone on. And then do it again at the Ferris wheel.

Instead, the operator takes your ticket and lets you through. The manager's cut is marked off in the operator's tally as soon as you pay. At closing time the operator cashes out only their share. The manager collects what was set aside throughout the day.

That's the part we tried on Solana's test network, devnet: set the fee aside when someone pays, collect it later. In Deed #1, we built a wallet dashboard that could send tokens. For Deed #2, we made the token, set a fee and followed it into the treasury.

A wallet isn't a balance

The show needs a rulebook and a tally for each operator. Solana stores both as records at addresses, called accounts.

The mint account is the rulebook for one kind of ticket. It says how many tokens exist, how the fee is worked out and who can collect it.

A token account is a tally for those tickets. The sender, the operator and the grounds manager each have one. The operator's tally has two numbers: what's theirs to spend and what's already set aside for the manager.

Your wallet holds the keys you use to sign a payment. Token-2022 checks the signature and updates the tallies. An operator's key can spend the operator's balance, but can't touch the part reserved for the manager.

There's another charge in the real transaction: the Solana network fee, paid in SOL. It's separate from the transfer fee, which is paid in the tickets we're following.

Keep the ride queue moving

flowchart LR
    A["Rider's token account"] -->|"Pay the operator"| B["Operator's token account<br/>Spendable balance + fee set aside"]
    B -->|"Collect the fee later"| T["Grounds manager's token account<br/>Treasury"]

We sent 1,000 tokens in the demo. At 2.5% (250 basis points), the fee was 25, below our cap of 30 tokens. The recipient got 975 to spend. The other 25 went into a separate field on the recipient's account called TransferFeeAmount. When we collected the fee, the treasury got 25. The recipient's spendable balance was still 975.

On Solana, the bottleneck isn't a manager walking between rides. It's the treasury account. Two transactions can't update the same account at once. If every payment had to credit the treasury, the dodgems and the Ferris wheel would have to take turns updating it even when they had nothing else in common.

Token-2022 already has to update the recipient's account, so it records the fee there and leaves the treasury alone until collection. We collected directly from the recipient's account. The program can also gather fees on the mint and collect them from there. Avoiding that queue is the reason for the design. We didn't benchmark it.

What the receipts show

Watch the Deed #2 demo on YouTube.

Browse the public source snapshot and devnet quickstart.

For the demo, we ran the steps from a fresh copy of the code. You can look up the transfer and the fee collection on Solscan, a site that shows what happened on-chain. Both transactions finalized on devnet. The terminal output shows what was in each account between those two receipts.

We also signed two dry runs with the wrong key: one to collect the fee and one to change the rate. Token-2022 said OwnerMismatch (4) both times. Neither attempt went on-chain, and the account balances didn't change. Our first check stopped because it read the error code in the wrong format. We fixed the check before counting the rejection as evidence.

Codex did the build in stages: get the fee to land, collect it, then show that the result could be reproduced. As in Deed #1, the journal mattered once we got to the video. We could trace each number back to its run and keep the later handover test separate from the wallet balances on screen.

One cut of the video opened with the missing 25 but hadn't told viewers what we were building. I asked to put the goal and the account primer first. Then we added Solscan screenshots and replays of the terminal output so you could follow the numbers yourself. The first upload used a synthetic voice. I've since recorded the narration myself.

Who can still make new tickets?

The key that sets the fee, the key that collects it and the key that makes new tickets are separate permissions. On a fresh devnet mint, we handed over the first two and removed the third in one finalized transaction. The supply stayed at 1,000. A dry run that tried to issue one more token got FixedSupply (5). Running the handover again just read back the new settings; it sent nothing.

We handed over the right to collect the fees and change the rate. The ticket printer is off for good. Holders can still burn tokens they already have. If you're looking up a token before you send it, check who can change the fee even if the mint authority says None.