I wanted a token that takes a small fee on every transfer and also grows over time. In a normal backend I would write a bunch of code. On Solana I found I could get both features just by flipping a few switches when creating the token. No smart contract needed.
Here's exactly what I did.
First I created a token called ArcCoin with a 1% transfer fee and an interest rate of 5 basis points. I used the Tokenβ2022 program because it supports these extra features (called extensions).
spl-token --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb create-token --decimals 2 --transfer-fee-basis-points 100 --interest-rate 5 --enable-metadata
I also added a name, symbol, and a link to an image.
spl-token initialize-metadata Huf3R4rC1wfzhX31RV6QHTG9RRcKA6dg9UgMZTHgS6UV "ArcCoin" "ARC"
Then I minted 1000 tokens to myself and tried sending 100 to a second wallet. That's when the transfer fee kicked in. I had to pass --expected-fee 1 because I knew 1 token would be taken. After the transfer, my balance was 900 and the recipient got 99. The missing 1 token was held by the token account.
I tried to collect that withheld fee using spl-token withdraw-withheld-tokens but I passed my wallet address by mistake. The command failed because it wanted a token account, not a regular wallet. Once I used the correct token account address, it moved the withheld token into the recipient's balance.
The big lesson for me was that these token extensions are just configuration stored inside the mint account. When I ran spl-token display on the mint, it showed me everything: interest rate, fee percentage, metadata, and authorities. I didn't need to write a smart contract at all.
If you're coming from Web2, think of token extensions like adding constraints to your database table. They just work. And you can combine them however you like.
I'm still learning, but building ArcCoin helped me understand that Solana gives you powerful building blocks right out of the box. You don't have to start from scratch.



Top comments (0)