Token-2022 transfer hooks
Two measurements first. Through real Token-2022, a transfer whose mint calls a hook that does nothing costs 12,352 CU when the hook program is written in Anchor and 8,169 when it is written in Pinocchio (psyto/pinocchio-bench, W7). And on Kamino's TSLAx reserve, run against mainnet state and binaries in LiteSVM (psyto/issuer-drill), the issuer setting a hook program made Kamino refuse TSLAx deposits, withdrawals with redemption, TSLAx repayments and liquidations of TSLAx-backed loans (UnsupportedTokenExtension), while USDC repayments and USDC lending still worked.
A Token-2022 mint with the transfer-hook extension names a program. On every transfer, Token-2022 calls that program's Execute instruction through a CPI, and the transfer fails if the hook returns an error. That is how a token can refuse transfers to wallets that have not passed a check such as KYC.
The hook usually needs more accounts than a transfer carries, such as each wallet's KYC record. It lists them in an account at the PDA ["extra-account-metas", mint] under the hook program. The client resolves those accounts from the list and appends them to the transfer (TransferChecked); Token-2022 checks them against the list and passes them to the hook. An entry can be, for example, a fixed address or a PDA whose seeds include bytes read from another account, such as the owner field of the source token account.
The mint's hook authority can point the mint at a different hook program or clear the hook. Anyone holding or accepting the token depends on who holds that authority, so it is worth reading alongside the issuer's other powers.
API at a glance
Execute: sha256("spl-transfer-hook-interface:execute")[..8] = [105, 37, 101, 197, 75, 251, 102, 26]- The 8-byte discriminator Token-2022 sends, followed by the transfer amount as a little-endian u64.
accounts: [0] source token account, [1] mint, [2] destination token account, [3] source authority, [4] extra-account-metas, then the listed extras- The order Execute receives its accounts in. princeps-solana's hook lists each wallet's KYC record as an extra account, derived from the owner field of accounts 0 and 2.
InitializeExtraAccountMetaList: sha256("spl-transfer-hook-interface:initialize-extra-account-metas")[..8]- Creates the extra-account-metas account for a mint. In princeps-solana only the mint authority can do this.
ExtraAccountMetaList: [8-byte Execute discriminator][u32 length][u32 count][35-byte ExtraAccountMeta]…- The byte layout Token-2022 reads: a TLV entry keyed by the Execute discriminator, wrapping a PodSlice of 35-byte entries. Each entry describes one account, for example a fixed address or a PDA described by seed configs (such as literal bytes, or bytes read from another account's data).
Checked against psyto/princeps-solana at f316295 (2026-11-06): programs/psol-compliance/src/lib.rs
Related parts
- issuer-drill
Runs the issuer's powers, setting a transfer hook included, against Kamino's mainnet lending binary in LiteSVM and shows which operations stop.
- princeps-solana (psol-compliance)
A KYC transfer hook for Token-2022 in Pinocchio: refuses a transfer unless both wallets are verified in its registry.
- issuer-powers
Reads what a mint's issuer can do to holders, including the transfer hook and who can change it, and grades the mint.
Lessons on this topic
In short: a CPI (cross-program invocation) is one program calling another — with invoke, or with invoke_signed when a PDA has to sign. A signer of the…
In short: a PDA (program-derived address) is an address computed by hashing the seeds, a one-byte bump, the program ID and a fixed marker with sha256,…