Solana Account Model: How your data and program are stored on Solana

tosynthegeektosynthegeek
3 min read

In the world of blockchain technology, Solana stands out for its innovative approach to storing data and executing programs. At the heart of this uniqueness lies the Solana Account Model – a concept that might initially seem challenging but holds the key to unlocking new possibilities for developers.

In this article, we'll delve into the intricacies of this model and explore how you, as a developer, can harness its power.

Demystifying Solana's Account System

Accounts are used for storing data on the Solana blockchain. Accounts have the remarkable capability to store various data types, from valuable tokens like SOL to a program’s state variables such as integers, strings, public keys, and even entire programs themselves.

How Solana's Account Model improve Solana compared to other blockchains

In other chains, transactions occur in sequence (one at a time), while in Solana, transactions are processed in parallel and this is made possible through the unique Solana Account Model among other concepts.

In Ethereum smart contracts, data and state variables are stored within the contract itself. This limitation means that performing actions like retrieving data and transferring assets simultaneously becomes intricate, making it less possible to run transactions in parallel on Ethereum.

In comparison to Solana programs (Smart Contracts in Solana are called Programs), the program and the data/state of the account are separated into accounts. So the program in itself is stateless, it does not hold any data in it. This makes it easy for transactions to run in parallel without conflicts.

Types of Accounts

Recalling that accounts can store any data type, they are categorized into two based on the data type they hold:

  • Executable accounts: are accounts that are used for storing only program code.

  • Non-executable accounts: accounts used to hold all other needed data. Example token balances, variables for a program.

Rent

These accounts are stored in the validator's memory and require “rent” to be maintained. Rents are storage costs required to keep accounts alive. This is because validators have to store these accounts which costs them, so every account pays rent to keep the account active.

But there is this cool thing called rent-exempt, which means that if an account holds 2 years' worth of rent, the account becomes exempt from further payments.

You can easily check the rent cost of storage size (in bytes) using the Solana rent command through the Solana Command Line Interface (CLI).

Ownership Dynamics

Every account on Solana is owned, by default, by a built-in program called the “System Program”. Ownership can, however, be transferred from the Solana System Program to other programs. There are a few things to note about ownership and permission of accounts:

  • Only the owner of an account can change the account’s owner.

  • Once a program has been finalized, it cannot be changed; it can however be replaced.

  • Programs can read or credit any account but only the owner of the account can debit it.

Conclusion

The Solana Account Model serves as the foundation for Solana's impressive capabilities which gives developers the power to create efficient applications that can run in parallel, pushing the boundaries of blockchain speed and scalability.

To delve deeper into the Solana ecosystem or embark on your journey of building on Solana, the Solana Dev Resource is an excellent starting point.

10
Subscribe to my newsletter

Read articles from tosynthegeek directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

tosynthegeek
tosynthegeek

I love reading about web3