> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# API 参考

> LiteSVM 完整的 TypeScript API 参考

在 `@solana/kit` 及其插件生态系统中使用 LiteSVM 的
完整 API 文档。

## API 分类

<Columns cols={2}>
  <Card title="账户管理" href="/developers/docs/tools/litesvm/typescript/api-reference/account-management">
    setAccount、getAccount、airdrop、getBalance
  </Card>
  <Card title="交易" href="/developers/docs/tools/litesvm/typescript/api-reference/transactions">
    sendTransaction、simulateTransaction、blockhash 管理
  </Card>
  <Card title="配置" href="/developers/docs/tools/litesvm/typescript/api-reference/configuration">
    用于配置 LiteSVM 的 Builder 方法
  </Card>
  <Card title="时间与 Sysvars" href="/developers/docs/tools/litesvm/typescript/api-reference/time-and-sysvars">
    时钟操作与 sysvar 访问
  </Card>
</Columns>

## 快速参考

### 插件设置

```typescript
import { createClient, generateKeyPairSigner } from "@solana/kit";
import { litesvm } from "@solana/kit-plugin-litesvm";
import { signer } from "@solana/kit-plugin-signer";

const mySigner = await generateKeyPairSigner();
const client = createClient().use(signer(mySigner)).use(litesvm());
// client.svm: LiteSVM instance
// client.rpc: RPC compatibility layer
```

### 账户管理(client.svm)

| 方法                                 | 描述                   |
| -------------------------------------- | ----------------------------- |
| `setAccount(account)`                  | 直接设置账户状态    |
| `getAccount(address)`                  | 获取账户数据         |
| `getBalance(address)`                  | 获取 SOL 余额               |
| `airdrop(address, lamports)`           | 为账户充值               |
| `minimumBalanceForRentExemption(size)` | 计算免除 rent 的最低余额 |

### 程序管理(client.svm)

| 方法                                | 描述                |
| ------------------------------------- | -------------------------- |
| `addProgram(programId, bytes)`        | 从字节加载程序    |
| `addProgramFromFile(programId, path)` | 从 .so 文件加载程序 |

### 交易(client.svm)

| 方法                    | 描述                    |
| ------------------------- | ------------------------------ |
| `sendTransaction(tx)`     | 执行交易          |
| `simulateTransaction(tx)` | 模拟交易(不改变状态) |
| `latestBlockhash()`       | 获取当前 blockhash          |
| `expireBlockhash()`       | 推进到新的 blockhash       |

### 配置(client.svm)

| 方法                      | 描述                           |
| --------------------------- | ------------------------------------- |
| `withSigverify(bool)`       | 启用/禁用签名验证 |
| `withBlockhashCheck(bool)`  | 启用/禁用 blockhash 验证   |
| `withSysvars()`             | 将 sysvar 重置为默认值       |
| `withBuiltins()`            | 启用内置程序              |
| `withPrecompiles()`         | 启用预编译程序           |
| `withTransactionHistory(n)` | 存储最近 n 笔交易             |
| `withComputeBudget(budget)` | 设置计算限制                    |
| `withLamports(amount)`      | 设置空投水龙头余额        |
| `withLogBytesLimit(n)`      | 设置日志输出限制                  |

### 时间与 Sysvars(client.svm)

| 方法                     | 描述           |
| -------------------------- | --------------------- |
| `warpToSlot(slot)`         | 跳转到指定 slot |
| `getClock()`               | 获取 clock sysvar      |
| `getRent()`                | 获取 rent sysvar       |
| `getEpochSchedule()`       | 获取 epoch 计划    |
| `getLastRestartSlot()`     | 获取最后一次重启的 slot |
| `setLastRestartSlot(slot)` | 设置最后一次重启的 slot |

### RPC(client.rpc)

| 方法                           | 描述                        |
| -------------------------------- | ---------------------------------- |
| `getAccountInfo(address)`        | 获取单个账户(仅支持 base64) |
| `getMultipleAccounts(addresses)` | 获取多个账户            |
| `getLatestBlockhash()`           | 获取当前 blockhash              |
