1

In Ethereum, the only native asset is Ether (ETH). It's the only asset that gets first-class treatment in terms of cost and ability to be pushed and pulled through contract calls.

Is there a similarly clear-cut distinction between SOL and all other tokens on Solana?

For instance, are the SOL balances stored in a different place compared to SPL tokens?

2 Answers 2

3

No, the SOL balance of an account is not located in the same place than another token.

For example (querying account info with a wallet address):

result = await connectionMainnet.getParsedAccountInfo(new SolanaWeb3.PublicKey('DRA8e6NGeHU7NPpjbEwDgdPVQYDEQT4Da1coYeoeg2ac'));

You will get the SOL balance in result.value.lamports

For example (querying account info with an associated token account)

result = await connectionMainnet.getParsedAccountInfo(new SolanaWeb3.PublicKey('BifCf622nKhaqSTup3xDpjVzY43SuCeo3sCQ3epPZHmF'));

You will get the Token (DUST) balance in result.value.data.parsed.infos.tokenAmount.amount

Note that there is also a SOL balance in each token account (linked to rent exemption)

So, SOL is not considered as a token like any other token.

2
  • Thanks! This explains everything. Just curious though how could one obtain the SOL balance for the DUST token account BifCf622nKhaqSTup3xDpjVzY43SuCeo3sCQ3epPZHmF? It looks like you are using the same method (getParsedAccountInfo) for both accounts. And I couldn't find any info about the SOL balance (related to rent exemption) on the explorer. Sep 18, 2023 at 9:51
  • 1
    for the dust token accounts you can get the SOL balance in result.value.lamports (same as the 1st call). You can see the sol balance in solscan => solscan.io/account/BifCf622nKhaqSTup3xDpjVzY43SuCeo3sCQ3epPZHmF Explorer doesn't display it, i don't know why
    – Effe2
    Sep 18, 2023 at 13:28
3

TL;DR - the difference lies in which program owns the account. Your normal wallet address is owned by the System Program while your spl-token are owned by the token program

To answer this, you first have to understand the account model on Solana. On Solana everything is an account.

According to the solana cookbook

There are 3 kinds of accounts on Solana: Data accounts store data Program accounts store executable programs Native accounts that indicate native programs on Solana such as System, Stake, and Vote.

Wallet addresses fall under the first account type, data account and under this account type, your balance will be stored under the lamports field.

enter image description here

For spl-tokens, they are owned by the token program. When minting new tokens there the fields for account owner will be the address for the token program.

sidenote, if you are new to Solana, do not confuse owner to authority

1
  • 1
    Thanks. You said the "third account type" but then mentioned "data account", which appears first in the quoted text. Which account type did you want to reference? Sep 16, 2023 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.