Pattern: Max Balance (Concentration Limit)
Create a token with per-wallet balance caps to prevent concentration violations
Overview
The max balance hook enforces a maximum token holding per wallet. Transfers that would push a wallet above the limit are rejected. Common for preventing concentration violations in regulated offerings (Reg D/S investor limits, fund diversification rules).
Implementation
Updating the Limit
Key Points
- The hook reads the destination token account balance at byte offset 64 and checks
balance + amount <= maxBalance updateMaxBalance()takes effect immediately — all future transfers use the new limit- Wallets already above the new limit are not affected, but cannot receive more tokens
- Use
toggleActive(false)to temporarily bypass all max balance checks - Set
maxBalanceto0is invalid and will fail withInvalidMaxBalance