Accounts vs. programs: a Solana mental model
If you arrive from Ethereum, your first instinct is to treat a program like a contract that owns its storage layout internally. On Solana that layout is inverted: programs are stateless executors, and every persistent byte lives in an account with an owner field pointing back to a program ID.
Why the split exists
Solana optimizes for parallel execution. The runtime needs to know, before running your instruction, which accounts might change. That is only practical when state is addressable independently of the program binary. Your counter value is not hidden inside the program; it sits in an account whose address your client passes into the transaction.
Ownership and writes
An account’s owner program is the only code allowed to modify its data or debit its lamports (with narrow system-program exceptions). When your Anchor test fails with an unauthorized write, check whether the account owner matches the program under test and whether the instruction marked the account mutable.
Upgrade implications
Deploying a new program version does not migrate account data automatically. If you change account layout, you need an explicit migration instruction or new accounts. Workshop participants often discover this when adding a field to a struct that already exists on devnet.
Rent enters the picture
Accounts cost lamports to reserve space. Data-heavy designs must budget rent-exempt minimums. Our glossary entry on rent lists the formula; this article’s takeaway is that rent is a design constraint you plan for when choosing account sizes, not a runtime surprise.
A minimal counter example
Imagine a counter stored in a single account struct with one u64 field. The program exposes increment and initialize instructions. Initialize creates the account with enough lamports to be rent-exempt. Increment loads the account, adds one, serializes back. The client always passes the counter account’s public key — the program never “looks up” state by itself.
Reading explorer output
After your first devnet deploy, open the transaction on Solana Explorer. You should see account keys listed with writable flags. Matching those flags to your instruction definition builds intuition faster than reading diagrams alone.
Next: Picking a local dev stack before day one · Related session: First dApp Builder Workshop