Skip to content

Latest commit

History

History
75 lines (47 loc) 路 3.19 KB

08_token_extensions.md

File metadata and controls

75 lines (47 loc) 路 3.19 KB

馃浌 Token Extensions


tl; dr


  • 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.



Creating a Token with Token Extensions



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


Demo




Resources