Back to Course
4/8
Complete35 XP
hybrid15 min

Understanding Accounts

Deep Dive: Solana Account Model

The Account Model Deep Dive

Every piece of data on Solana lives in an account. This is fundamentally different from Ethereum where contracts store their own state.

Account Types

  • System Accounts — Your wallet. Owned by the System Program.
  • Program Accounts — Executable code. Marked with executable: true.
  • Data Accounts — Store state for programs. Owned by the program that created them.
  • Token Accounts — SPL Token balances. Owned by the Token Program.
  • Account Layout

    pub struct AccountInfo<'a> {
    

    pub key: &'a Pubkey, // 32 bytes - account address

    pub lamports: &'a mut u64, // 8 bytes - SOL balance

    pub data: &'a mut [u8], // variable - stored data

    pub owner: &'a Pubkey, // 32 bytes - program owner

    pub rent_epoch: u64, // 8 bytes - rent tracking

    pub is_signer: bool, // 1 byte - signed this tx?

    pub is_writable: bool, // 1 byte - writable in tx?

    pub executable: bool, // 1 byte - is a program?

    }

    Think of the Solana runtime as a key-value store where keys are public keys (addresses) and values are account data.

    Rent

    Accounts must maintain a minimum balance to stay alive — this is called rent exemption. The minimum is approximately:

    rent = 0.00089088 SOL per byte per year
    

    For a typical account with 100 bytes of data, you need about 0.00144768 SOL to be rent-exempt.

    Most modern Solana programs require accounts to be rent-exempt at creation time.

    Hints

    0/2 revealed
    🔒 Hint 2 — reveal previous hints first