When starting your learning journey in Solana, it's very important to focus on the fundamentals. One such concept that often feels difficult when getting into blockchain, especially Solana development, is the Solana accounts model.
In this blog, we are going to simplify one of the core concepts of the Solana blockchain: the account model.
As always, if you have any feedback or opportunities where I can provide value, feel free to reach out to me here:
Let’s get started with the topic!
Solana stores everything as a key-value store: the key is the account address (or public key) that you own, and attached to it is the account information.
Here’s a representation of this:
Now, everything you’ve heard about in blockchain—tokens, NFTs, your wallet, etc.—has its own account. The only difference is the functionality or what they can do.
The account information associated with each account address has the following data structure:
Key Data Fields in Solana Accounts:
Data -> This depends on the account's purpose, and the data stored will vary accordingly. For example, a wallet account stores the Solana balance or token information it holds. If the account is a smart contract, it will store executable code.
Executable-> This field is either true or false. In the case of a smart contract, it will be true because it has executable logic. In other cases, such as a wallet, it will be false.
Lamports -> This represents the account balance in lamports, the smallest unit of SOL (1 SOL = 1 billion lamports)..
Owner -> *Specifies the public key *(program ID) of the program that owns the account.
The owner is crucial because it determines what actions can be performed on the account. Think of the owner as having the rights to modify the data. For example, in the case of a wallet, the owner can decrease the balance or transfer tokens.
For example:
If the owner is the System Program, it can handle basic wallet management tasks.
If the owner is the BPF Loader, it can run smart contracts.
Here’s a visual representation of how the owner is involved in the process:
From the above, you can see how the owner differs in terms of what it can do, and how it governs the actions that can be performed on the account.
Next we are going to learn about some native programs and how data is stored on Solana. Stay tuned, for further blog posts.
Top comments (0)