Solana's original SPL Token standard powered billions of dollars in volume, but enforcing custom transfer logic—such as mandatory royalties, compliance checks, or transfer fees—required fragile off-chain wrappers or non-standard contract bridges.
With Token-2022 (SPL Token Extensions) , transfer hooks are executed natively by the token program itself on every single transfer , regardless of which AMM, marketplace, or wallet initiates it.
In this walkthrough, we’ll build a production-grade Anchor 0.30+ program implementing the SPL Transfer Hook Interface .
🏗️ How Transfer Hooks Work
Unlike Ethereum where transfer logic is bundled inside the ERC-20 contract, Solana separates data accounts from execution programs:
sequenceDiagram autonumber actor Alice as Sender (Alice) participant TokenProg as Token-2022 Program participant HookProg as Your Anchor Transfer Hook participant ExtraMeta as ExtraAccountMetas PDA
Alice->>TokenProg: TransferChecked(amount) TokenProg->>ExtraMeta: Read required validation…