> ## 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.

# 通过公开链接分享模拟

> 让已执行的 Tenderly 模拟可供任何持有链接的人查看，复制公开 URL，并通过 dashboard 或 API 关闭公开访问。

分享模拟后，其结果页面（调用追踪、事件、状态变更、资金流向和 gas 分析）可通过公开 URL 查看。查看者无需 Tenderly 账户。要分享由接收者自行运行的 [Simulator](/simulator-ui/overview) 设置，请改用 [draft 链接](/simulator-ui/draft-links)。

## 从 dashboard 分享模拟

<Steps>
  <Step title="打开模拟">
    在 **Simulator** 中，从列表中打开一个模拟，或运行一个新模拟。
  </Step>

  <Step title="打开 Share 菜单">
    点击 **Simulation** 标题旁边的 **Share**。模拟处于私有状态时，**Share** 会显示锁形图标。
  </Step>

  <Step title="启用公开访问">
    打开 **Enable public access**，然后点击 **Copy URL**。

    <Frame caption="已启用公开访问的 Share Simulation 菜单。">
      <img src="https://mintcdn.com/tenderly/PzoXOFG6RNM2SCxQ/images/simulator-ui/share-simulation-popover.webp?fit=max&auto=format&n=PzoXOFG6RNM2SCxQ&q=85&s=29213150c5f432e97a4be6c0af9dfce3" alt="从 Simulation 标题旁的 Share 按钮打开的 Share Simulation 菜单，Enable public access 开关已打开，下方有 Copy URL 按钮" width="640" height="230" data-path="images/simulator-ui/share-simulation-popover.webp" />
    </Frame>
  </Step>
</Steps>

复制的 URL 格式为 `https://www.tdly.co/shared/simulation/<simulation-id>`，会重定向到 `https://dashboard.tenderly.co/shared/simulation/<simulation-id>`。未登录的查看者会在 **SIMULATION** 标签下看到完整的结果页面。

<Frame caption="未登录时打开的共享模拟。">
  <img src="https://mintcdn.com/tenderly/PzoXOFG6RNM2SCxQ/images/simulator-ui/share-simulation-public-view.webp?fit=max&auto=format&n=PzoXOFG6RNM2SCxQ&q=85&s=66a6f22f791d57346640c7065491265b" alt="未登录状态下打开的共享模拟页面，顶部栏显示 Log in / Register，页面带有 SIMULATION 标签、一笔来自 0xe2e2...e2e2 的 WETH 存款交易详情以及调用追踪" width="1600" height="720" data-path="images/simulator-ui/share-simulation-public-view.webp" />
</Frame>

## 停止分享模拟

点击 **Share** 并关闭 **Enable public access**。此后打开该链接的任何人都会看到“Sorry, you don't have access to this page.”

## 通过 API 分享模拟

使用 [Enable simulation sharing](/api-reference/simulator/enable-simulation-sharing) 和 [Disable simulation sharing](/api-reference/simulator/disable-simulation-sharing) 端点启用和禁用公开访问。这两个端点都在路径中接收模拟 ID，没有请求体，成功时返回 `204 No Content`。

```bash title="share-simulation.sh" theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
curl -X POST \
  "https://api.tenderly.co/api/v1/account/$TENDERLY_ACCOUNT_SLUG/project/$TENDERLY_PROJECT_SLUG/simulations/$SIMULATION_ID/share" \
  -H "X-Access-Key: $TENDERLY_ACCESS_KEY"
```

要停止分享，请向 `/unshare` 路径发送相同的请求。公开 URL 为 `https://www.tdly.co/shared/simulation/$SIMULATION_ID`。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.