-
The Transfer Hook extension and Transfer Hook Interface allow users to create Mint Accounts that execute custom instruction logic on every token transfer.
-
To achieve this, developers must build a program that implements the Transfer Hook Interface and initialize a Mint Account with an enabled Transfer Hook extension.
-
For every token transfer involving tokens from the Mint Account, the Token Extensions program invokes a Cross-Program Instruction (CPI) to execute an instruction on the Transfer Hook program.
- You can use the Solana Tool Suite (see chapter 4) to create tokens with a CLI:
spl-token --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb create-token <extension flags>
- These are the flags to add to create tokens with each type of extension:
- Mint Close Authority:
--enable-close
- Transfer Fees :
--transfer-fee <basis points> <max fee>
- Non-Transferable: `--enable-non-transferable``
- Interest-Bearing:
--interest-rate <rate>
- Permanent Delegate:
--enable-permanent-delegate
- Transfer Hook:
--transfer-hook <programID>
- Metadata:
--enable-metadata
- Metadata Pointer:
--metadata-address <accountId>
- Confidential Transfers:
--enable-confidential-transfers auto
- Mint Close Authority:
- Token Extensions on Solana Developer Guides (Youtube)
- How to use the Mint Close Authority extension, by Solana Foundation
- How to use the Transfer Fee extension, by Solana Foundation
- How to use the Permanent Delegate extension, by Solana Foundation
- How to use the Metadata Pointer extension, by Solana Foundation
- How to use the Non-transferable extension, by Solana Foundation
- How to create soulbound tokens, by Solana Foundation
- How to use the Interest-Bearing extension, by Solana Foundation
- How to use the Required Memo token extension, by Solana Foundation
- How to use the Default Account State extension, by Solana Foundation
- Token-2022 Program official docs, by Solana Foundation