The impact of Token2022 on Solana NFTs
This article is the second piece of a series on new digital ownership models on Solana. If you haven’t already, I suggest you read the first piece entitled “What’s wrong with Metaplex”.
In this article, we will explore the new Solana token standard: Token2022. It is a lot more powerful than the current SPL standard and will unleash a wave of innovation on Solana. We will first go over the way tokens work on Solana before diving into the new features enables by Token2022. We will then look at how these can be leveraged to create the best possible metadata standard, based on the weaknesses identified in the last article.
How do Solana tokens work?
There are many things that Solana does differently from most other blockchains. The most important distinction is how data is handled. This change impacts how everything works on Solana so we’ll quickly go over this. We’ll take Ethereum and the Ethereum Virtual Machine (EVM) as the reference to explain how Solana differs.
One implementation to rule them all
Solana’s programs are just accounts that store some bytecode and that are marked as executable. Executing a program’s instructions simply run the bytecode stored in the the program account while providing it with the relevant accounts. This architecture makes Solana programs stateless: the bytecode, once deployed, never changes as the result of executing a transaction.
Solana’s account model therefore favors generic implementation: since you can have a single program spawn many data accounts, so you might as well use the same program for many different use-cases. This is the spirit that guided the leading token standard on Solana, the one from the Solana Program Library (SPL).
Differences with Ethereum tokens
In contrast, for the EVM, a program is one large account that also contains all its relevant data: memory allocated during interactions is added directly in the program’s data. Doing a token transfer on the EVM means calling the program account of the token but it will modify its own data to reflect the changes in balances caused by the transfer.
This led to many different token programs being released on the EVM, where each has to be independently audited. It however allows for more freedom in the way token programs work on the EVM.
There are also big differences that come from the parallel execution of Solana, but we’ll not be exploring this topic yet.
The downsides of the current SPL implementation
Although it is more secure because there are less ways left for devs to mess the implementation, the current implementation lacked a lot of flexibility. Ethereum tokens can do all sorts of funny logic on transfers, with the current SPL implementation, you basically had to create a wrapper token and a custom program to tackle some use cases, while other were simply infeasible.
Moreover, in the pursuit of reducing rent costs, SPL mints were not closable, costing the minters fees that could not be regained when the token became useless. This is especially important for NFTs, where each token has its own mint.
Token2022 to the rescue
Thankfully, the Solana Foundation has been hard at work to provide a new and better implementation called Token2022. At the time of writing, Token2022 is still being audited and not fully production ready but its final version is getting closer and the most important features are already well defined.
Moreover, just like the current SPL programs, Token2022 will be made immutable as soon as it finishes audits. This helps build trust in tokens for users, because you can simply check what each token can currently do and know that it will not change beyond what is defined, as opposed to upgradeable programs that can technically rug you at any time.
Backward compatibility
The first important strength of this new implementation is its backward compatibility. Except for transfers which now have to use the “transfer_checked” instruction rather than the basic “transfer” (which was already recommended), every other instruction just works. This means that you can seamlessly use tokens from Token2022 with old programs without the fear of breaking everything.
Extensions
The second most important feature is Token2022’s modularity. The concept of extensions allows developers and token creators to simply whatever extension they want in their mint. These extensions enables many new functionalities, and we’ll go over the one relevant for NFTs.
- Mint Close Authority. We can add this extension to allow an account to close the mint. This is useful to allow completely burning an NFT, unlike the partial burning that is currently available.
- Permanent Delegate. Adding this extension allows one account to act as a delegate for any token account using the created mint. Using this extension, we can for example have one program transfer a token without the current owner consenting, if some programmed rule allows it. This is interesting because it enables new programmatic ownership models but it can also be a large security flaw.
- Transfer Hooks. When interacting with a token that has this extension, a defined program respecting a given interface will be called. Similar to permanent delegate, transfer hooks allows creating custom and more advanced ownership models and much more. It is however a lot more complex than a permanent delegate because all transfers have to execute those hooks and creating them is still a little tricky given the stage of developement of Token2022.
- Metadata Pointers. You can now write directly in the mint what the canonical metadata is. This is useful to prevent ambiguity but it increases the size of the mint for a limited upside.
- Metadata. It is now possible to include metadata directly in the mint using this extension. However, the metadata format currently defined still suffers from some of the issues outlined in the previous article.
Conclusion
We’ve seen how Solana tokens worked so far and how the new Token2022 standard can change the game. Using extensions, we can now create tokens that rival with EVM tokens in terms of craziness.
When it comes to building the new NFT metadata standard and revolution ownership models, it is clear that Token2022 can offer all the tools we need. In the next article, we will go over what our ideal implementation of a NFT metadata standard looks like in practice, going over the proof of concept implementation, so make sure to subscribe and stay tuned for next week!