Building a Token-2022 Transfer Hook with Anchor 0.31.1

How can a builder make a Token-2022 transfer fail when its amount exceeds a limit? A tutorial published on November 15, 2026, at 09:16:31 (UTC+8) walks through a Devnet example using Anchor 0.31.1 and the SPL Transfer Hook interface.

The example covers the hook interface and the ExtraAccountMetaList PDA—a program-derived account used to identify additional accounts needed by the hook. It also explains how the PDA’s seeds are resolved on-chain, how its type-length-value (TLV) data is initialized, and how Anchor’s fallback routing addresses an instruction-discriminator mismatch.

For the Devnet workflow, the tutorial shows how to create a mint with a hook using the spl-token CLI, initialize the PDA, and call the initialization instruction from TypeScript. It then tests both outcomes: a transfer above the limit fails, while a transfer within the limit succeeds. These are the tutorial’s reported Devnet results, not a claim about a production deployment.

Source: learnblockchain.cn (originally published 2026-11-15 09:16 UTC+8)

Further reading