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

# Simulation Bundles

> 运行最多五笔共享状态的模拟交易，每一步都能看到之前的变更。在模拟构建器中构建和检查多步骤流程。

一个 simulation bundle 会**按顺序针对共享状态运行最多五笔交易**：每一步都能看到前一步所做的状态变更。当一笔交易依赖于另一笔时，请使用 bundle，例如允许后续 `transferFrom` 的授权，或者一笔存款供后续提取消耗。

Bundle 使用与单次模拟相同的构建器。单次模拟就是一步的 bundle，因此在您添加更多步骤时编辑器不会有任何变化。

<Frame caption="三步 bundle：顶部是会话条带，左侧是步骤栏，右侧是聚焦步骤的结果。">
  <img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/simulator-ui/sim-bundle-builder-3steps.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=fb17e42a65febce9f35464edd350a95f" alt="Simulator UI showing three steps in the bundle rail and step results on the right" width="1600" height="1000" data-path="images/simulator-ui/sim-bundle-builder-3steps.webp" />
</Frame>

## 构建 bundle

从 **Simulator → New Simulation** 开始，像往常一样配置第一步。然后从左侧的栏中扩展 bundle：

* 使用步骤卡片下的 **+** 按钮**添加步骤**。
* 使用导入按钮**导入交易**：粘贴现有的交易哈希或原始负载，其输入将作为新步骤加载。
* 通过拖动卡片**重新排序**步骤。步骤按栏中的顺序执行。

每个步骤在所有方面都是独立的（除了状态）：它有自己的 Decoded/Raw 切换、自己的 **From** 覆盖，以及自己的一组 [cheatcodes](/simulator-ui/parameters#cheatcodes)（gas 和 value 覆盖、已充值地址、区块和时间戳操作、状态覆盖、访问列表）。Cheatcodes 在它们所属的步骤之前立即运行。

Bundle 是执行的单位：点击 **Simulate** 会按顺序一次运行所有步骤，使用会话条带中配置的网络和区块。

## 阅读结果

运行后，栏中的每个步骤卡片会显示一个结果徽章：

| 徽章   | 含义                                       |
| ---- | ---------------------------------------- |
| 绿色对勾 | 步骤成功。                                    |
| 红色 ✗ | 步骤 revert 或 EVM 之前失败（畸形的 calldata、未知合约）。 |

点击任何步骤卡片，即可在右侧面板中聚焦其单独的结果：解码输出、已使用的 gas，以及该步骤的 Events、State、Fund Flow 和 Gas Profiler 标签页。

状态只向前流动。步骤 1 铸造的余额对步骤 2 到 5 可见，但后续步骤中的 revert 不会撤销显示输出中前面步骤的结果；每个步骤的视图反映了该步骤在序列中位置时的状态。

## 模拟历史中的 bundle

已执行的 bundle 在 **Simulator** 列表中显示为一行 `Bundle (N txs)`，显示共享的网络、区块和调用计数。展开该行可查看每个步骤作为独立条目，及其单独的状态和函数。

<Frame caption="Simulator 列表：展开的 bundle 显示其按步骤划分的行，下方是折叠的 Bundle (3 txs) 行。">
  <img src="https://mintcdn.com/tenderly/5rOzguRoBTCVuzKW/images/simulator-ui/sim-bundle-history.webp?fit=max&auto=format&n=5rOzguRoBTCVuzKW&q=85&s=61815de215655590f9ffdc2eaa77d239" alt="Simulator list with an expanded bundle row showing individual mint, approve, and transferFrom steps, and collapsed Bundle rows with call counts" width="1512" height="982" data-path="images/simulator-ui/sim-bundle-history.webp" />
</Frame>

## 限制

* 每个 bundle 五个步骤。
* Cheatcodes 是步骤范围的。没有 bundle 级别的 cheatcode 界面。
* Bundle 在运行之间是无状态的：重新运行会从配置的区块重新开始。要在多笔交易之间累积状态的持久环境，请使用 [Virtual Environments](/virtual-environments/overview)。

## 完整示例

[模拟代币 Mint、Approve 和 TransferFrom Bundle](/simulations/guides/mint-approve-transfer-bundle) 构建了一个完整的 3 步 DAI bundle，包括让 mint 成功的状态覆盖和分步结果。

要以编程方式运行 bundle，请参阅 Simulation API 中的 [Bundled Simulations](/simulations/bundled-simulations)。
