> ## 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 项目，以跟踪所有直接和内部交易、运行模拟并配置告警。

了解如何将智能合约添加到项目中，并在 Dashboard 中跟踪其交易。添加合约后，您将看到与该合约关联的所有历史交易（直接和内部）列表。

<img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/developer-explorer/contracts/contract-overview-page.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=2764b407a37e12f01cae02c6cda6542c" alt="Transaction Overview" width="4608" height="2852" data-path="images/developer-explorer/contracts/contract-overview-page.webp" />

## 如何将合约添加到项目

1. 在侧边菜单中导航到 **Contracts**。
2. 点击 **Add Contract**。
3. 输入合约地址，选择其部署网络，分配名称，然后点击 **Add Contract**。

<img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/developer-explorer/contracts/add-contract.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=9bca3edec101cf7375473a21f7f7f7e7" alt="Transaction Overview" width="3716" height="2434" data-path="images/developer-explorer/contracts/add-contract.webp" />

尝试将以下合约之一添加到您的项目以开始使用。在 Tenderly 中打开该合约，点击 **Add to Project** 按钮，将其添加到现有项目。了解[如何在 Tenderly 中创建项目](/platform/account/projects/overview)。

* [Uniswap Router](https://www.tdly.co/contract/1/0x1cf9cbe70a84137c696f98587a9b06f7fa2b71b4)：`0x1cf9cbe70a84137c696f98587a9b06f7fa2b71b4`
* [veCurveVault proxy](https://www.tdly.co/contract/1/0xc5bddf9843308380375a611c18b50fb9341f502a)：`0xc5bddf9843308380375a611c18b50fb9341f502a`

## 从任何网络添加已验证的合约

Dashboard 的搜索功能允许您查找部署在任何[104 个受支持网络](/platform/supported-networks)上的已验证合约。

<img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/developer-explorer/contracts/search-contract.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=093ef39fd276229985e512f9889cda01" alt="Transaction Overview" width="3804" height="2522" data-path="images/developer-explorer/contracts/search-contract.webp" />

1. 在顶部菜单搜索栏中粘贴合约的地址或名称。
2. 从搜索结果中选择合约。

要将合约添加到项目，点击 **Add to Project** 并选择目标项目。

## 查看合约详情

在 **Contracts** 页面，点击合约以查看其详情，例如：

* 源代码、ABI、字节码、创建代码和源代码映射
* 交易历史和筛选选项
* 已模拟的交易历史

<img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/developer-explorer/contracts/inspect-contract.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=1594519d2ef89d82827b2beb2f47d2fc" alt="Inspecting a contract" width="3804" height="2522" data-path="images/developer-explorer/contracts/inspect-contract.webp" />

您还可以修改参数模拟合约的任何交易。点击 **Simulate Transaction** 按钮以模拟交易。查看此指南以了解如何模拟交易：

<Card title="How to Simulate Transactions from the Dashboard" href="" />

## 为合约添加标签

在处理多个合约时，您需要一种方式将它们组织起来。这就是标签发挥作用的地方。您可以点击 **Add Tag** 链接为合约添加标签。

标签还允许您使用 Alerts 监控归入同一标签下的多个合约或钱包。

<img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/developer-explorer/contracts/tag-contract.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=5a2c4e39dd7903ab7a3895097778f7e2" alt="Tagging contracts" width="3804" height="2522" data-path="images/developer-explorer/contracts/tag-contract.webp" />

## 使用 Alerts 监控合约

您可以设置 Alerts 以实时监控合约上的活动。要创建 Alert，请从合约概览页面点击 **Create Alert** 按钮。

<img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/developer-explorer/contracts/contract-alert.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=f944d7e29d506337bf58c44555050e15" alt="Contract alert" width="4320" height="2522" data-path="images/developer-explorer/contracts/contract-alert.webp" />

通过 Alerts，您可以监控各种事件，例如失败或成功的交易、函数调用、发出的事件、被阻止的调用者等。

<img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/developer-explorer/contracts/alerts-page.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=2c5e58f84dc393966649e03b2eb02c64" alt="Alerting page" width="4320" height="2522" data-path="images/developer-explorer/contracts/alerts-page.webp" />

您可以从 12 种以上的触发器类型中进行选择，并在 Slack、Telegram 等位置接收通知，或将数据发送到 [Sentry](/monitoring/alerts/destinations/account-scoped#sentry-destination) 和 [PagerDuty](/monitoring/alerts/destinations/account-scoped#pagerduty-destination)。

<Card title="How to Create and Manage Smart Contract Alerts" href="" />

## 代理合约

Tenderly 会自动检测 [EIP-1967](https://eips.ethereum.org/EIPS/eip-1967) 和 [EIP-1167](https://eips.ethereum.org/EIPS/eip-1167) 代理。当合约的实现发生更改时，Tenderly 会自动识别并在 Dashboard 中显示版本历史记录。

要访问实现历史记录，请点击**时钟图标**。

<img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/developer-explorer/contracts/contract-implementations.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=559b57b3d768267877b66ca361168259" alt="Contract implementation history" width="5344" height="3054" data-path="images/developer-explorer/contracts/contract-implementations.webp" />

### 非标准代理实现

对于非标准解决方案，您需要手动将合约转换为代理。

首先，点击合约页面右上角的**三点图标**，然后选择 **Convert to Proxy**

<img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/developer-explorer/contracts/contract-proxy-button.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=b3cb3f7b0faea8f21292f7b2f5dfcf33" alt="Contract proxy button" width="4320" height="2522" data-path="images/developer-explorer/contracts/contract-proxy-button.webp" />

**设置包含实现地址的存储槽**，或**选择一个返回实现地址的 view 函数**。

<img src="https://mintcdn.com/tenderly/XsEZlaGXYskrtN68/images/developer-explorer/contracts/contract-proxy-modal.webp?fit=max&auto=format&n=XsEZlaGXYskrtN68&q=85&s=9fe588b291a1c5b647a51f0268d41510" alt="Contract proxy modal" width="4320" height="2522" data-path="images/developer-explorer/contracts/contract-proxy-modal.webp" />
