DEV Community

NIRANJAN LAMICHHANE
NIRANJAN LAMICHHANE Subscriber

Posted on

Intrest bearing token in solana

Create an Interest‑Bearing Token on Solana (Token‑2022) – Step by Step

Learn how to mint a token that earns interest automatically, every second, using Solana’s Token‑2022 program.

No staking, no separate contracts – just a CLI and a wallet.


1. Prerequisites

  • Solana CLI & SPL Token CLI installed
  • A funded wallet (devnet/testnet)
  • Basic terminal comfort

2. Create the Mint (with 5% interest)

The --interest-rate is in basis points (bps).

500 bps = 5% APY.

spl-token create-token \
  --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb \
  --interest-rate 500
Enter fullscreen mode Exit fullscreen mode

Sample output mint address (yours will differ):

CRXKmUj2dVcJhr6uH5YVduZ352YdUeSxYT2WEvPA66Vu


3. Create a Token Account for Your Wallet

spl-token create-account <MINT_ADDRESS> \
  --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
Enter fullscreen mode Exit fullscreen mode

(My created account: 9nSZ154gJQ8H2qzgLV8mk7K5N4LbngViksUyrzsgncn1)


4. Mint 1000 Tokens

spl-token mint <MINT_ADDRESS> 1000 \
  --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
Enter fullscreen mode Exit fullscreen mode

5. Observe the Growing Balance

Check UI balance (applied interest)

spl-token balance <MINT_ADDRESS> \
  --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
Enter fullscreen mode Exit fullscreen mode

Result right after mint: 1000.000362839 – already more than 1000!

Inspect mint metadata

spl-token display <MINT_ADDRESS> \
  --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
Enter fullscreen mode Exit fullscreen mode

You’ll see:

SPL Token Mint
  …
  Supply: 1000000000000   (raw supply, 1000 tokens with 9 decimals)
  Decimals: 9
  Interest-bearing:
    Current rate: 500bps
    Average rate: 500bps
    Rate authority: …
Enter fullscreen mode Exit fullscreen mode

Key insight: The on‑chain supply never changes.

The UI balance grows because the program calculates interest per second from the last update time.

See raw account data (optional)

solana account <MINT_ADDRESS> --output json
Enter fullscreen mode Exit fullscreen mode

Returns a base64‑encoded blob – that’s where the interest rate and timestamp live.


6. Wait and Watch Interest Compound

After a few minutes, run spl-token balance again.

The number will be larger – without any transaction.


7. Change the Interest Rate

As the rate authority, you can update the rate anytime.

spl-token set-interest-rate <MINT_ADDRESS> 15000   # 150% APY
Enter fullscreen mode Exit fullscreen mode

Check display again – Current rate now shows 15000bps.

Balance will start climbing much faster.

Later I set it to 30000 (300% APY) and balance quickly went to 1000.015285823.


8. Rate Limits

The rate is stored as a 16‑bit signed integer (i16).

Max allowed: 32767 bps (~327.67% APY).

Min allowed: -32768 bps (negative interest, for demurrage tokens).

Trying 35000 or 100000 will error:

error: number too large to fit in target type
Enter fullscreen mode Exit fullscreen mode

My Full Command History (Reference)

spl-token create-token --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb --interest-rate 500
spl-token create-account CRXKmUj2dVcJhr6uH5YVduZ352YdUeSxYT2WEvPA66Vu --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
spl-token mint CRXKmUj2dVcJhr6uH5YVduZ352YdUeSxYT2WEvPA66Vu 1000 --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
spl-token balance CRXKmUj2dVcJhr6uH5YVduZ352YdUeSxYT2WEvPA66Vu --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
# 1000.000362839
spl-token display CRXKmUj2dVcJhr6uH5YVduZ352YdUeSxYT2WEvPA66Vu --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb
solana account CRXKmUj2dVcJhr6uH5YVduZ352YdUeSxYT2WEvPA66Vu --output json
spl-token set-interest-rate CRXKmUj2dVcJhr6uH5YVduZ352YdUeSxYT2WEvPA66Vu 15000
spl-token balance … # 1000.008316801
spl-token set-interest-rate CRXKmUj2dVcJhr6uH5YVduZ352YdUeSxYT2WEvPA66Vu 30000
spl-token balance … # 1000.015285823
Enter fullscreen mode Exit fullscreen mode

Why This Matters

  • Yield‑bearing stablecoins without external protocols
  • Automatic savings tokens that reward holders per second
  • Dynamic rates – adjust APY on the fly based on market conditions
  • Fully on‑chain, permissionless, composable

Now go build your own interest‑bearing token. Happy hacking! 🚀

Top comments (0)