> ## 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 完整的 Go API 参考

`litesvm-go` v0.3.0 及更高版本的完整 API 文档。方法名称尽可能与 Rust 版
`LiteSVM` builder 保持一致;getter / setter 成对方法遵循相同的 Go 约定
(`Clock` / `SetClock`、`Rent` / `SetRent` 等)。账户为普通的
`*solana.Account` 值,sysvar 则使用
`github.com/gagliardetto/solana-go/sysvar` 中的类型。

## API 分类

<Columns cols={2}>
  <Card title="账户管理" href="/developers/docs/tools/litesvm/go/api-reference/account-management">
    Airdrop、Balance、GetAccount、SetAccount、NewAccount、程序
  </Card>
  <Card title="交易" href="/developers/docs/tools/litesvm/go/api-reference/transactions">
    发送 / 模拟 legacy 与 versioned 交易,TxOutcome
  </Card>
  <Card title="配置" href="/developers/docs/tools/litesvm/go/api-reference/configuration">
    sigverify、blockhash 检查、历史记录、日志限制、默认程序的开关
  </Card>
  <Card title="时间与 Sysvar" href="/developers/docs/tools/litesvm/go/api-reference/time-and-sysvars">
    WarpToSlot、Clock、Rent、EpochSchedule、EpochRewards、SlotHashes、SlotHistory、StakeHistory
  </Card>
</Columns>

## 快速参考

### 句柄设置

```go
import (
    litesvm "github.com/LiteSVM/litesvm-go"
    solana "github.com/gagliardetto/solana-go"
)

svm, err := litesvm.New()
if err != nil {
    // handle error
}
defer svm.Close()
```

### 账户管理

| 方法                                                                       | 说明                                          |
| ---------------------------------------------------------------------------- | ---------------------------------------------------- |
| `Airdrop(pubkey, lamports) error`                                            | 为账户充值                                      |
| `Balance(pubkey) (uint64, bool, error)`                                      | SOL 余额;bool 表示该账户是否存在 |
| `GetAccount(pubkey) *solana.Account`                                         | 账户的副本(不存在则为 nil)                 |
| `SetAccount(pubkey, *solana.Account) error`                                  | 直接存储账户状态                         |
| `MinimumBalanceForRentExemption(dataLen int) (uint64, error)`                | 计算 rent 豁免所需的最低余额                          |
| `NewAccount(lamports, data, owner, executable, rentEpoch) (*solana.Account, error)` | 构建可用于 SetAccount 的账户(直接使用 `&solana.Account{...}` 字面量同样可行) |

### 程序管理

| 方法                                                   | 说明                             |
| -------------------------------------------------------- | --------------------------------------- |
| `AddProgram(programID, bytes) error`                     | 从字节加载程序                 |
| `AddProgramFromFile(programID, path) error`              | 从 `.so` 文件加载程序            |
| `AddProgramWithLoader(programID, bytes, loaderID) error` | 使用指定的加载器加载(高级) |

### 交易

| 方法                                                                        | 说明                                                                     |
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `SendLegacyTransaction(txBytes) (*TxOutcome, error)`                          | 执行 legacy 交易                                                    |
| `SendVersionedTransaction(txBytes) (*TxOutcome, error)`                       | 执行 v0+ 交易                                                       |
| `SimulateLegacyTransaction(txBytes) (*TxOutcome, error)`                      | 模拟执行,不改变状态                                                  |
| `SimulateVersionedTransaction(txBytes) (*TxOutcome, error)`                   | 模拟执行 v0+ 交易,不改变状态                                              |
| `LatestBlockhash() (solana.Hash, error)`                                      | 当前 blockhash                                                               |
| `ExpireBlockhash() error`                                                     | 推进到新的 blockhash                                                      |
| `GetTransaction(signature) *TxOutcome`                                        | 在历史记录中查找交易(不存在则为 nil)                                  |
| `litesvm.BuildTransferTx(payerSeed, to, lamports, blockhash) ([]byte, error)` | 测试辅助函数,无需引入 `solana-go` 即可构建已签名的 legacy 转账交易 |

### 配置

| 方法                                         | 说明                                             |
| ---------------------------------------------- | ------------------------------------------------------- |
| `SetSigverify(bool) error`                     | 启用 / 禁用签名验证                 |
| `Sigverify() (bool, error)`                    | 读取当前设置                                |
| `SetBlockhashCheck(bool) error`                | 启用 / 禁用 blockhash 校验                   |
| `SetTransactionHistory(int) error`             | 内存中交易历史的容量(0 表示禁用)           |
| `SetLogBytesLimit(int) error`                  | 单笔交易的日志字节上限(负数表示不限制)              |
| `SetLamports(uint64) error`                    | 重置空投池余额                          |
| `SetSysvars() error`                           | 将 sysvar 重置为默认值                               |
| `SetBuiltins() error`                          | 重新加载内置程序                                |
| `SetDefaultPrograms() error`                   | 重新加载 SPL Token、Memo 等程序                            |
| `SetPrecompiles() error`                       | 启用 ed25519 / secp256k1 预编译程序                  |
| `WithNativeMints() error`                      | 预置 wrapped-SOL mint                                   |
| `SetFeatureSet(*FeatureSet) error`             | 安装功能开关集合                              |
| `SetComputeBudget(ComputeBudget) error`        | 应用计算预算                                  |
| `ComputeBudget() (ComputeBudget, bool, error)` | 读取当前预算(bool 表示是否已“显式设置”) |

### 时间与 Sysvar

| 方法                                       | 说明                          |
| -------------------------------------------- | ------------------------------------ |
| `WarpToSlot(slot uint64) error`              | 跳转到指定的 slot              |
| `Clock() (*sysvar.Clock, error)`             | 读取 Clock sysvar                |
| `SetClock(*sysvar.Clock) error`              | 覆盖 Clock sysvar           |
| `Rent() (*sysvar.Rent, error)`               | 读取 Rent sysvar                 |
| `SetRent(*sysvar.Rent) error`                | 覆盖 Rent sysvar            |
| `EpochSchedule() (*sysvar.EpochSchedule, error)` | 读取 EpochSchedule sysvar    |
| `SetEpochSchedule(*sysvar.EpochSchedule) error` | 覆盖 EpochSchedule sysvar |
| `EpochRewards() (*sysvar.EpochRewards, error)` | 读取 EpochRewards sysvar       |
| `SetEpochRewards(*sysvar.EpochRewards) error` | 覆盖 EpochRewards sysvar   |
| `LastRestartSlot() (*sysvar.LastRestartSlot, error)` | 读取 last-restart-slot       |
| `SetLastRestartSlot(*sysvar.LastRestartSlot) error` | 设置 last-restart-slot         |
| `SlotHashes() (sysvar.SlotHashes, error)`    | 读取 SlotHashes sysvar           |
| `SetSlotHashes(sysvar.SlotHashes) error`     | 覆盖 SlotHashes sysvar      |
| `SlotHistory() (*sysvar.SlotHistory, error)` | 读取 SlotHistory sysvar          |
| `SetSlotHistory(*sysvar.SlotHistory) error`  | 覆盖 SlotHistory sysvar     |
| `StakeHistory() (sysvar.StakeHistory, error)` | 读取 StakeHistory sysvar        |
| `SetStakeHistory(sysvar.StakeHistory) error` | 覆盖 StakeHistory sysvar    |

### 实用工具

| 方法                     | 说明                                                    |
| -------------------------- | -------------------------------------------------------------- |
| `litesvm.Version() string` | 引擎描述(`litesvm-go (mithril svm, pure go)`) |
