DEV Community

Parnita Singh
Parnita Singh

Posted on

Making my own tokens: what I learned from Solana token extensions

When I first started working with Solana tokens I thought creating one would be as simple as generating a mint and assigning balances to wallets.

But after spending a few days touring Token-2022, I realized there’s much more to it.

I moved from a basic token to trying out transfer fees, metadata, interest-bearing balances, frozen accounts and even non-transferable tokens.

And here is what I learned in the process.

What are Token Extensions first?

Solana has two main token programs:

  • Original Token Program: Core functionality for creating, minting, transferring, and burning tokens.

  • Token-2022 (Token Extensions Program) : Builds on those capabilities with additional features that developers are able to configure for their tokens.

Extensions are optional features that change how a token behaves without having to write an entirely new token program.
**
What I attempted**

In the last few days I worked with several extensions:

  1. Extended Metadata

A token is more than an address. It can have a name, symbol and metadata URI. I played around with putting the metadata right on the mint account so the token is easier to identify for wallets and explorers.

  1. Extension of transfer fee

Interestingly, the fee is enforced by the Token-2022 Program itself.

A configured percentage is withheld on transfers and can be collected later by authorized withdrawal authority . You don’t have to build a separate fee handler at the application level.

  1. Extension with Interest

One of my favorite experiments!

I did create a token that shows a higher balance over time but the actual number of tokens recorded in the account does not change.

The extension stores an interest rate and a timestamp so that compatible applications can calculate the adjusted display amount using continuous compounding.

  1. Account State Default

I tested adding tokens in cases where new token accounts are frozen. To perform regular token operations, an account must first be thawed by the freeze authority.

This enables the permissioned token systems.

  1. Non-Transferable Token & Perpetual Delegate

I also experimented with soulbound-style tokens that cannot be moved from one wallet to another.

That also resulted in a fifth interesting use case: with a permanent delegate: revokable credentials (such as memberships, certificates of courses, proof-of-attendances).

What was the biggest surprise to me?

Because I spent my first years in Web2, my first thought was to do these features on the backend.

Such as using payment middleware for transfer fees, some scheduled jobs for interest calculations, permission to enforce for some level of checks, etc.

Token-2022 adds many of these features to the protocol itself.

It forces rules you've set rather than "hoping" each app does the right thing.

Final Thoughts

What started out as learning how to create and transfer a token turned into learning how digital resources can have their own rules, permissions, and behaviors.

The biggest lesson for me is that a token is more than just the token you hold or transfer. It can contain credentials, enforce fees, hold metadata, and so many other more advanced use cases.

I'm still learning the Solana ecosystem, but these experiments have been very useful in helping me understand the Token-2022 architecture.

Top comments (1)

Collapse
 
bloqarl profile image
Carlos | Zealynx •

Once a pool or vault holds your token, those extensions become its problem too. Orca's Whirlpool program checks every Token-2022 mint before it opens a pool: transfer fees and interest-bearing pass, but a permanent delegate or default frozen accounts need a token badge from Orca first, and non-transferable is a flat no (checked in their util/v2/token.rs). Makes sense when you think about it, a permanent delegate can move or burn tokens out of any account of that mint, the pool's vault included.