> ## 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 上验证智能合约，以解码其交易、事件和状态变化，并根据原始 Solidity 源代码调试执行。

合约验证是提交已部署合约的源代码，以便 Tenderly 可以将其与链上字节码进行匹配。一旦验证，Tenderly 就可以在以下位置解码该合约的交易、事件和状态变化：

* **解码的交易**：调用跟踪、事件、状态变化和 gas 使用变得可读。
* **Debugger**：根据原始 Solidity 逐步执行，设置优先级，并对跟踪进行评论。
* **Gas 分析器**：针对源代码的行级 gas 归因。
* **共享**：与协作者和审计师共享已验证的合约。

如果没有验证，您将在触及该合约的每个 Tenderly 工具中看到原始字节码。

## 选择方式

对于**公共网络**（主网和测试网）上的验证，请选择匹配您工具链的指南：

* [Dashboard](/contract-verification/dashboard)：仅通过 Tenderly Dashboard 从浏览器进行验证。
* [Foundry](/contract-verification/foundry)：`forge verify-contract` 以及使用 `forge create` / `forge script` 部署并验证。
* [Hardhat](/contract-verification/hardhat)：`@tenderly/hardhat-tenderly` 插件，自动或手动。
* [Hardhat（代理合约）](/contract-verification/hardhat-proxy)：UUPS、Transparent 和 Beacon 代理。

要在 **Virtual Environment** 上验证合约，请参阅 Virtual Environments 下的[部署并验证合约](/virtual-environments/develop/deploy-contracts)和[使用 Foundry 验证代理合约](/virtual-environments/develop/verify-proxy-contracts)。

## 公开与私密可见性

在**公共网络**上，您可以在两种可见性模式之间选择：

* **公开验证。** 源代码对 Tenderly 上的所有人可见，并传播到公共验证注册表。
* **私密验证。** 源代码仅在您的 Tenderly 项目和组织内可见。

在 **Virtual Environments** 上，验证始终限定于您的项目和组织。没有公开模式；请参阅[部署并验证合约](/virtual-environments/develop/deploy-contracts)。

| 谁可以查看已验证的源代码   | 公开验证（公共网络） | 私密验证（公共网络） | Virtual Environment |
| -------------- | :--------: | :--------: | :-----------------: |
| 所有 Tenderly 用户 |      ✓     |            |                     |
| 项目协作者          |      ✓     |      ✓     |          ✓          |
| 组织成员           |      ✓     |      ✓     |          ✓          |

如何切换到私密模式取决于所使用的方法：

* **Hardhat**：在 `hardhat.config.ts` 中设置 `tenderly.privateVerification: true`。请参阅 [Hardhat 设置](/contract-verification/hardhat#configure-authentication-and-verification-visibility)。
* **Foundry**：在验证器 URL 后附加 `/public` 以公开验证，省略它以私密验证。请参阅 [Foundry 验证器 URL](/contract-verification/foundry#verifier-url)。
* **Dashboard**：在验证对话框中切换 **Make Private**。请参阅 [Dashboard 验证](/contract-verification/dashboard#public-and-private-verification)。
