What is Solana Storage?
Learning about the Solana world is a must for many people interested in a decentralized future. Digging deeper, we can see that Ethereum and Solana have very different infrastructures. To understand these differences, let’s start with the basics.
First, it’s important to understand that Solana storage is based on Programs and Accounts. Let’s break this down further.
Key Points:
- Accounts can store arbitrary data
- Each account has a unique address
- All accounts hold SOL
- Account data storage is paid with rent
- Accounts are passed into programs, allowing for parallel execution
Programs in Solana
Programs are executable code that function as smart contracts. In Solana, programs are stored as accounts and organized into functions called instructions.
Each program can process incoming transactions and perform specific actions based on the instructions provided.
Account Model
In the Solana network, all information is stored in special containers called accounts. Each account has a unique 256-bit address that identifies it. This data storage system is similar to a regular database where the account address serves as a key to find the corresponding information.
The maximum size of an account is limited to 10 MB, and the data structure within the account is strictly defined.
Account Information
Let’s examine several important fields stored in AccountInfo.
{
key: number, // The address of the account
lamports: number, // Lamports currently held (1 Lamport = 10E-9 SOL)
data: Uint8Array, // The raw data byte array stored by this account
executable: boolean, // Is this data a program?
owner: PublicKey, // The program owner of this account
}
Here are some key ownership rules:
- Only the account owner can make changes to the data stored within the account and spend lamports from it.
- Anyone can add lamports to an account.
- The account owner can transfer ownership to someone else if the account’s data is completely cleared.
Rent
To store data on the blockchain, a certain amount of SOL needs to be transferred to an account. The amount transferred is proportional to the size of the data stored in the account. This concept is commonly referred to as rent.
However, “rent” can be seen more as a “deposit” because the SOL allocated to the account can be fully refunded when the account is closed.
There are two main types of accounts in Solana: those that can run programs (executable) and those that can’t (non-executable). This difference happens because in Solana, programs don’t store their own data directly, like smart contracts in Ethereum.
For example, if you have a program that counts how many times it’s been used, you need to create two accounts: one for the program code and another to store the counter.
That’s why we need to separate these two types of actions:
- Executable Programs: These are unchangeable bytecode that can create and manage other accounts, which are used to store changing data.
- Non-Executable Programs: These are used to store data that can change on Solana. They hold all the information apps need, like token balances, NFT metadata, and other user data.
Executable and non-executable accounts can be further classified into three main types: native programs, program accounts, and data accounts.
Native Programs
Originally built into the Solana ecosystem, native programs are its “building blocks”. T
hey are responsible for the most fundamental network functions: launching and maintaining nodes that validate transactions (validators), creating and managing user accounts (wallets), implementing the staking mechanism (where users delegate their tokens to earn rewards), and deploying smart contracts, similar to how the EVM does it in Ethereum.
Program Accounts
Think of program accounts as Lego sets. They let you build other, more specific programs.
For example, the SPL library has a Token program that lets you “build” different kinds of tokens, like USDC. But the tokens themselves aren’t stored inside the Token program. They’re kept in separate data accounts, just like Lego pieces are kept in different boxes.
Data Accounts
They are like a record that shows how things change for specific programs and for the whole Solana network.
Data accounts can be divided into:
- Token accounts: These represent different kinds of tokens (like USDC, USDT).
They hold the main information about the token: total amount, number of decimal places, name, etc.
- Associated token accounts (ATAs): These store the balances of specific tokens for each user. They are linked to token accounts.
- System accounts: These store system data and are used to sign transactions.
If you have USDC and USDT tokens, there are two token accounts: one for USDC and one for USDT.
For each of your wallets that holds these tokens, there are separate ATAs that are linked to the corresponding token accounts. So, your USDC balance will be stored in one ATA, and your USDT balance will be stored in another.
Start Building on Solana
Solana’s infrastructure, fundamentally different from Ethereum’s, opens new horizons for developing applications. With its high transaction throughput and low fees, Solana becomes an attractive platform for projects demanding high performance. This, in turn, fosters the growth of the decentralized industry.
Contents
YOU MAY ALSO LIKE
Defending Against DoS: Strategies to Prevent Denial of Service Attacks in Smart Contracts
Education
Explore how DoS attacks like Unexpected Reverts, Block Gas Limits, and Block Stuffing disrupt Solidity smart contracts. Learn security methods to safeguard your blockchain projects.
Why Smart Contract Audits are Non-Negotiable
Education
Unlock Web3's full potential by securing your smart contracts. Learn why audits are essential, explore real-world risks, and see how Oxor.io fortifies your blockchain projects against threats.
Mastering Access Control Issue: Ensuring Only Authorized Interactions with Your Contract
Education
Explore how access control vulnerabilities led to the $7 million GAMEE Token hack. Learn from code examples, discover prevention strategies, and see how OXORIO can secure your blockchain projects.
Integer Overflows and Underflows
Education
Learn about the risks of integer overflows and underflows in Solidity smart contracts. Discover how to mitigate these vulnerabilities using SafeMath and Solidity's built-in checks to enhance your blockchain project's security with OXORIO.
Have a question?
Stay Connected with OXORIO
We're here to help and guide you through any inquiries you might have about blockchain security and audits.