Customizing Your Tokens with Extensions
Now that you know what extensions are available, you can create your new token with the following command:
spl-token --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb create-token
You can combine multiple extensions together, but some extensions would either not work or not make sense to combine. (For example, you would not want to add token hooks alongside the non-transferable token extension because it would add anything to the token but still cost more to create.)
Extension Combinations
- Non-transferable + {transfer hooks, transfer fees, confidential transfer}
- Confidential transfer + fees (available in 1.18)
- Confidential transfer + transfer hooks (can only see source / destination, can’t act on amount)
Other than these exceptions, you have the option to customize with any combination of token extensions that suit your project’s needs.
Token extensions enable you to create custom logic with your tokens while retaining full composability with dApps, wallets, programs. The two extensions that can enable this are the transfer hooks and metadata extensions.
Transfer Hooks
Transfer hooks are a powerful new extension that give token issuers greater ability to dictate how users and tokens interact. Now, any developer can insert custom logic into a program to be used with the transfer hook extension. With transfer hooks, you can enable capabilities such as enforced on-chain royalties, enabling more elaborate token interactions.
It is important to note that while transfer hooks give the capability to insert custom logic within a transfer, all accounts from the initial transfer are converted to read-only accounts. This means that the signer privileges of the sender do not extend to the transfer hook program. This is to avoid potential unexpected logic executing on someone’s wallet who interacts with a token with transfer hooks, protecting the users.
Start building with transfer hooks today.
Metadata
The Metadata extension empowers token issuers by allowing them to seamlessly embed diverse key-value pairs on-chain, all within a single account. This functionality is particularly beneficial for projects like games, enabling them to incorporate custom metadata within each token. This opens up a myriad of possibilities for games to enhance the capabilities of their in-game tokens and items. Furthermore, the inclusion of custom on-chain metadata paves the way for the establishment of new standards. This presents a unique opportunity for the developer community to collaboratively explore innovative applications of on-chain metadata, all encapsulated under the umbrella of token extensions.
Start building with metadata today.
Standard Compatibility
Token extensions is a new standard for tokens, but it is not a requirement that anyone migrate from one standard to another. There are reasons why you may want to stick with the original Token standard. If you only need a transfer and freeze functionality and none of the additional features of token extensions, the Token program standard will suit your project just fine. However if you want the ability to add more advanced features, token extensions can help.
There is no way to automatically convert your tokens across standards today. A migration path does exist between the token standards, but it comes with some complications:
- All tokens of the previous standard must be burned
- The migration will be user opt-in only
The general recommendation is that if you want token extension capabilities for your token, start with creating your token with that standard.
Token extensions offer a flexible and powerful way to customize your tokens with advanced features and capabilities. By combining extensions, you can create unique and innovative experiences for your users. Whether you’re building a game, a dApp, or a wallet, token extensions can help you achieve your project’s goals.
Q: What is a token extension?
A: A token extension is a feature that can be added to a token to enable advanced functionality.
Q: What types of token extensions are available?
A: Some examples of token extensions include transfer hooks, metadata, and more.
Q: Can I combine multiple token extensions?
A: Yes, you can combine multiple token extensions, but some combinations may not work or make sense.
Q: What is the advantage of using token extensions?
A: Token extensions enable you to create custom logic with your tokens while retaining full composability with dApps, wallets, and programs.
Q: Can I upgrade my token from the original standard to token extensions?
A: Yes, a migration path does exist, but it requires burning all tokens of the previous standard and will be user opt-in only.