Goal: Think in accounts and instructions.
Cover: System Program, rent exemption, owners vs signers, data serialization (Borsh), sysvars.
Activity: Write a program that initializes and updates a state account.
Takeaway: “I can design account layouts and mutate them safely.”
1) Module overview
On Solana, everything is an account: balances, program code, and your program’s state. Programs cannot edit accounts they don’t own. The System Program creates new accounts and assigns ownership. Accounts must hold enough lamports to be rent‑exempt (a refundable storage deposit). You’ll learn core fields, how instructions carry data, and how to size and serialize your state.
2) Plain‑English explainer
Account fields (the mental model)
- lamports: SOL held by the account, including the rent‑exempt deposit so data can persist. Closing a data account returns its lamports.
- owner: Only the owner program may modify the account’s data or debit lamports. Your program must own its state accounts.
- data (bytes): Fixed‑size region whose layout you define and serialize (e.g., Borsh). Plan space up front.
- executable: true for program accounts; false for data accounts.
Creating program state (who does what?)
- The System Program creates the account and assigns ownership to your program.
- Then your program initializes the data. This two‑step “create → initialize” pattern is everywhere.
Rent and rent‑exemption (what to know now)
- Accounts must hold a minimum lamport balance based on size to be rent‑exempt. Use the RPC helper to compute it. Conceptually: about two years of byte‑rent prepaid.
Owners vs signers (different roles)