Where the fee goes on each transfer
When someone sends a Token-2022 token that has the transfer fee extension, the token program
takes the fee out of the amount received. The sender's balance drops by the full amount,
the recipient's spendable balance rises by the amount minus the fee, and the fee itself is
recorded as a withheld amount on the recipient's token account.
That withheld amount cannot be spent or moved by the holder. It belongs to whoever holds the
mint's withdraw withheld authority. On a token minted with Anvilmint, that is the wallet
that created it. Anvilmint's code passes your connected address as that authority and never
an address of its own, so we could not collect your fees even if we wanted to.
How much is withheld
The fee is the rate times the amount transferred, rounded up to the token's smallest unit.
Anvilmint lets you set a rate from 0.1% to 10% and an optional cap: the most that can be
withheld from any single transfer, in whole tokens. Some examples:
A trade on a DEX is a transfer too, in both directions, so a buy and a later sell are each
charged. That is the point of a transfer fee, and it is also why rates above a few percent
tend to stop trading altogether.
Two ways the fees reach your wallet
The token program offers two routes, and the right one depends on how many accounts hold
withheld fees.
Withdraw straight from holder accounts
Your wallet, as withdraw authority, sends one transaction listing token accounts that hold
withheld fees. The fees move from those accounts into a token account of yours. This needs
your signature and works well when a handful of accounts, such as a liquidity pool's vault,
hold most of the fees.
Harvest to the mint, then withdraw from the mint
Anyone can harvest: move withheld fees from many holder accounts onto the mint account
itself. No authority is needed, which is how holders clear an account before closing it.
Your wallet then withdraws everything sitting on the mint in one step. With hundreds of
holders this is the practical route, because a single transaction can only list so many
accounts.
Doing it in practice
- Find the accounts holding fees. An explorer such as Solscan lists your token's holders. The pool's token vault is usually the largest source, because every trade passes through it.
- Use a tool that signs with your wallet. Anvilmint's Collect Tax Fees tool does this for 0.1 SOL a run, with the network fee covered, and other Solana token tools offer the same. Developers can use the official spl-token command line tool, which has a withdraw-withheld-tokens command. Check its --help for the exact arguments in your version.
- Sign from the withdraw authority wallet. Any other wallet is rejected by the token program, so connect the one that created the token.
- Check the result. The collected tokens appear as a normal, spendable balance in your token account.
Never give a seed phrase or private key to anything that offers to collect fees for you. A
legitimate tool asks your wallet to sign, and your wallet shows you the transaction first.
What holders and buyers see
Everything about the fee is public. Explorers show the rate, the cap, the withdraw authority
and the config authority on the mint. Because your wallet holds the config authority, it can
change the rate, and buyers can see that it can. Token-2022 only applies a new rate two
epochs after it is set, roughly four to five days, so a change is never instant. If you want
holders to trust the rate, say publicly what it is for and leave it alone.
Support for Token-2022 still varies between wallets, DEXs and bridges. Check that the places
you want your token traded handle the transfer fee extension before you mint.
SPL vs Token-2022 covers the trade-off.