I'm a bit confused about spl_token (e.g. what is it for? what is fungible token for? how is it related to lamports?)

I’ve read: Token Program | Solana Program Library Docs – but I don’t quite understand what it is for.

As far as I understand, an account contains lamports and a token account (based on account) contains both lamports and fungible token that wraps around SOL (whatever this means). A token account’s data even contains “amount”, which seems redundant with the field: lamports.

I think, overall, I fail to understand why we use spl_token and the use cases for it. I wonder if anyone can help explain or point me to a resource that explains this.

Thank you!

So an SPL token is just a standard for creating any kind of new token on Solana, and it’s used pretty much all Solana tokens other than SOL, such as USDC, USDT, CATO, and everything else.

SPL tokens are a standard for how you can create new tokens, send tokens from one wallet to another, store tokens in a wallet, etc. By having spl_token it gives us all a way to make apps, such as exchanges, that can work with any SPL token, regardless of whether or not it’s USDC, CATO, ATLAS, or any other SPL token.

The way that tokens are stored is not very clear in the docs, so I know why you’re confused. It took a bit for it to make sense to me from the docs, but it’s actually not that complicated.

First, it’s important to understand that all data in Solana is stored in accounts. They are similar to files on your computer. If you need to store data it goes into an account. Also, every account in Solana can have lamports in it. These lamports are used to pay for the storage space used up by that account. Each account that doesn’t have lamports in it will get deleted eventually because of rent. So the lamports field in any account is just to pay for the account storage, and doesn’t effect that data that it actually stores.

Now, for a wallet to store any kind of SPL token, it needs to have some storage to track how much of that token the wallet has. That is what the associated token account is. So that associated token account will store how much of a particular kind of token is in a certain wallet.

Let me know if you still have questions!