# 验证合约

## 验证合约？

如果合约尚未验证，就无法通过 ConfluxScan 直观地获取信息或与之交互，此时就需要合约的部署者将完整的合约源码上传以验证合约。

&#x20;

![](/files/4AkRNqWLwx0DzTpmqknN)

### 上传源码

在上传合约源码前，先要填写一些相关信息，包括合约地址，合约名称(不是合约的 name 属性)，编译器版本，开源许可证书，是否优化等。然后就可以将源码复制粘贴到下方，点击 submit 提交即可。源码上传并验证成功之后，ConfluxScan 会在源码下方自动生成合约的 ABI 文件。

**注意**: 上传源码时，需要将源码所引用的所有的合约库也一并上传，并且在每个库合约之前都要指定其所使用的编译器，因此需要保证引用的库合约所使用的编译器版本要低于最终部署的合约所使用的编译器版本。

**Conflux-Truffle**&#x20;

使用 Conflux-Truffle 在VSCode 上开发可以安装 `Solidity Contract Flattener`插件，鼠标右键选择合约文件，在最下方选择 Solidity: flatten selected file(s) 可以将合约一键展平，获得一个包含所有源码的文件。

**Hardhat**

使用 Hardhat 框架则可以使用`npx hardhat flatten ./contracts/your_contract.sol > ERC20TokenMerged.sol` 命令来展平合约。

![](/files/t3e6OziGKHkQqwyO0fXk)

**本文简单介绍了在ConfluxScan上验证合约的过程，更详细资料和操作请见:**

ConfluxWiki - ConfluxScan 验证合约：<https://wiki.conflux123.xyz/books/tutorials/page/confluxscan>

Conflux Wiki - 如何在 Scan 上注册合约和代币展示: <https://conflux-wiki.github.io/conflux-wiki/development/register-contract-and-token-display/>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://conflux-technical-support.gitbook.io/conflux-nft-kai-fa-zhi-nan/step-1-ren-shi-confluxscan/yan-zheng-he-yue.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
