# Week 4: Understanding Solana’s Account Model as a Web2 Developer
Week 4: Understanding Solana’s Account Model as a Web2 Developer
第四周:作为 Web2 开发者理解 Solana 的账户模型
If you come from a Web2 background, Solana’s account model can feel confusing at first. You might ask: “Why does everything seem to be an account?” In traditional backend development, your application state usually lives in a database like PostgreSQL or MongoDB. Your server controls the logic, updates records, and manages permissions. On Solana, things work differently.
如果你有 Web2 背景,Solana 的账户模型起初可能会让你感到困惑。你可能会问:“为什么所有东西看起来都是一个账户?”在传统的后端开发中,应用程序的状态通常存储在 PostgreSQL 或 MongoDB 等数据库中。你的服务器负责控制逻辑、更新记录并管理权限。而在 Solana 上,情况则完全不同。
The Core Idea
核心理念
On Solana, everything is stored inside accounts. Think of an account as a structured container that holds:
- Data
- Tokens
- Program state
- Ownership information
在 Solana 上,一切都存储在账户中。你可以将账户想象成一个结构化的容器,其中包含:
- 数据
- 代币
- 程序状态
- 所有权信息
Instead of a centralized server managing a database, Solana stores application state directly on-chain inside these accounts.
Solana 不使用中心化服务器来管理数据库,而是直接将应用程序状态存储在链上的这些账户中。
A Web2 Analogy
Web2 类比
Here’s a simple comparison:
这是一个简单的对比:
| Web2 | Solana |
|---|---|
| Database row | Account |
| Backend server | Program |
| API endpoint | Instruction |
| User session | Wallet |
| Database update | Transaction |
If you have built a REST API before, you can think of a Solana program as your backend logic. But unlike Web2 servers:
- Programs are mostly stateless
- State lives in accounts
- Users sign transactions directly with wallets
如果你曾经构建过 REST API,你可以将 Solana 程序视为你的后端逻辑。但与 Web2 服务器不同的是:
- 程序大多是无状态的
- 状态存储在账户中
- 用户直接使用钱包签署交易
Programs vs Accounts
程序与账户
This is one of the biggest mindset shifts.
这是思维方式转变最大的一点。
Programs Programs contain executable logic. They are similar to backend services or server functions. However, programs do not store mutable state internally.
程序 程序包含可执行逻辑。它们类似于后端服务或服务器函数。然而,程序内部不存储可变状态。
Accounts Accounts store the actual data. For example:
- User profile data
- NFT metadata
- Token balances
- Game state
账户 账户存储实际数据。例如:
- 用户个人资料数据
- NFT 元数据
- 代币余额
- 游戏状态
When a Solana program runs, it receives accounts as input, modifies them if allowed, then saves the updated state back on-chain.
当 Solana 程序运行时,它接收账户作为输入,在允许的情况下修改它们,然后将更新后的状态保存回链上。
Ownership Matters
所有权至关重要
Every Solana account has an owner. The owner determines which program can modify the account’s data. Example: A token account is owned by the Solana Token Program. Your wallet may control the tokens, but only the token program can modify token balances. This creates strong security guarantees.
每个 Solana 账户都有一个所有者。所有者决定了哪个程序可以修改该账户的数据。 例如:代币账户由 Solana 代币程序(Token Program)拥有。你的钱包可能控制着代币,但只有代币程序才能修改代币余额。这提供了强大的安全保障。
Rent and Storage
租金与存储
Unlike traditional databases, blockchain storage is expensive. On Solana, accounts must hold enough SOL to remain active. This is called rent exemption. You can think of it like prepaying for storage space. The larger the account data, the more SOL required.
与传统数据库不同,区块链存储非常昂贵。在 Solana 上,账户必须持有足够的 SOL 才能保持活跃。这被称为“免租金”(rent exemption)。你可以将其想象成预付存储空间费用。账户数据越大,所需的 SOL 就越多。
Why This Model Exists
为什么存在这种模型
Solana’s account model is designed for:
- Parallel transaction execution
- High throughput
- Predictable state access
Solana 的账户模型旨在实现:
- 并行交易执行
- 高吞吐量
- 可预测的状态访问
Because transactions specify which accounts they will read or write beforehand, Solana can process many transactions simultaneously. This is one reason Solana achieves very high performance compared to many blockchains.
由于交易会预先指定它们将读取或写入哪些账户,Solana 可以同时处理大量交易。这就是为什么与许多区块链相比,Solana 能实现极高性能的原因之一。
Example Mental Model
示例思维模型
Imagine building a todo app. In Web2: Frontend sends request to backend -> Backend updates database -> Database stores todo item. In Solana: Wallet signs transaction -> Transaction calls a program -> Program updates a todo account -> Updated state is stored on-chain. The blockchain itself becomes the shared database.
想象一下构建一个待办事项应用。 在 Web2 中:前端发送请求到后端 -> 后端更新数据库 -> 数据库存储待办事项。 在 Solana 中:钱包签署交易 -> 交易调用程序 -> 程序更新待办事项账户 -> 更新后的状态存储在链上。 区块链本身成为了共享数据库。
Final Thoughts
结语
The hardest part of learning Solana is not syntax — it is changing how you think about application state. Once you understand that:
- programs execute logic
- accounts store state
- wallets authorize actions …the architecture starts making much more sense.
学习 Solana 最难的部分不是语法,而是改变你对应用程序状态的思考方式。一旦你理解了:
- 程序执行逻辑
- 账户存储状态
- 钱包授权操作 ……这种架构就开始变得更有意义了。
For Web2 developers, Solana development feels less like building a traditional backend and more like designing a distributed state machine. And that mindset shift is the key to understanding blockchain development.
对于 Web2 开发者来说,Solana 开发感觉不像是在构建传统的后端,而更像是在设计一个分布式状态机。而这种思维方式的转变,正是理解区块链开发的关键。