> For the complete documentation index, see [llms.txt](https://docs.rome.builders/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rome.builders/vi/huong-dan-cho-nha-phat-trien/verify-contracts.md).

# Xác minh hợp đồng

Xác minh mã nguồn hợp đồng Solidity trên Rome qua dịch vụ Sourcify được lưu trữ — các luồng chuẩn forge verify-contract và hardhat-verify, huy hiệu trên trình khám phá Via.

Rome vận hành một dịch vụ được lưu trữ [Sourcify](https://sourcify.dev) xác minh. Khi bạn xác minh một hợp đồng, mã nguồn và ABI của nó sẽ có thể được tái tạo công khai và hiển thị với một **✓ Mã nguồn đã được xác minh** huy hiệu trên trình khám phá khối Rome (Via).

Việc xác minh hoạt động với `forge verify-contract` và `hardhat-verify` luồng chuẩn — bạn chỉ cần trỏ chúng tới trình xác minh của Rome.

## Điểm cuối trình xác minh

| Môi trường        | URL của trình xác minh                    |
| ----------------- | ----------------------------------------- |
| Testnet & Devnet  | `https://verify.testnet.romeprotocol.xyz` |
| Mainnet (Rubicon) | `https://verify.mainnet.romeprotocol.xyz` |

Một phiên bản dùng chung phục vụ mọi chuỗi testnet/devnet của Rome — bạn chọn chuỗi bằng cờ chuẩn `--chain-id` cờ.

## Foundry

Sau khi triển khai (xem [Triển khai Hợp đồng Solidity](/vi/huong-dan-cho-nha-phat-trien/deploy-solidity.md)):

```bash
forge verify-contract <CONTRACT_ADDRESS> src/MyContract.sol:MyContract \
  --verifier sourcify \
  --verifier-url https://verify.testnet.romeprotocol.xyz/ \
  --chain-id <YOUR_CHAIN_ID> \
  --compiler-version 0.8.20
```

Nếu constructor nhận đối số, hãy truyền chúng để bytecode khớp:

```bash
  --constructor-args $(cast abi-encode "constructor(uint256)" 42)
```

Bạn cũng có thể xác minh ngay khi triển khai bằng `forge create … --verify` hoặc `forge script … --verify` (Foundry suy ra chain id từ `--rpc-url`).

## Hardhat

`hardhat-verify` đi kèm với bộ công cụ Hardhat 3. Trỏ nhà cung cấp Sourcify của nó tới trình xác minh của Rome trong `hardhat.config.ts` và chạy `hardhat verify`:

```typescript
export default defineConfig({
  // …các plugin, Solidity, mạng…
  verify: {
    etherscan: { enabled: false },
    blockscout: { enabled: false },
    sourcify: {
      enabled: true,
      apiUrl: "https://verify.testnet.romeprotocol.xyz",   // mainnet Rubicon: "https://verify.mainnet.romeprotocol.xyz"
    },
  },
});
```

```bash
npx hardhat verify --network <your-network> <CONTRACT_ADDRESS> [constructor args…]
```

Khi thành công, trình xác minh sẽ liên kết mã nguồn đã công bố, ví dụ: `https://verify.testnet.romeprotocol.xyz/repo-ui/<CHAIN_ID>/<ADDRESS>`.

## Kiểm tra trạng thái xác minh

Trình khám phá đọc trạng thái xác minh từ API của trình xác minh. Bạn có thể truy vấn trực tiếp:

```bash
curl https://verify.testnet.romeprotocol.xyz/v2/contract/<CHAIN_ID>/<ADDRESS>
```

Một hợp đồng đã được xác minh trả về một `khớp` trường:

* **`exact_match`** — bytecode *và* khớp hash metadata (một khớp hoàn hảo, "đầy đủ").
* **`khớp`** — bytecode khớp; metadata khác hơi khác một chút (vẫn là một khớp xác minh thực sự).
* `404` / `null` — chưa được xác minh.

## Ghi chú

* Việc xác minh chỉ cần bytecode đã triển khai của hợp đồng + mã nguồn và các thiết lập trình biên dịch bạn gửi — cùng các đầu vào như trên bất kỳ chuỗi EVM nào.
* Các chuỗi Rome mới sẽ được tự động thêm vào trình xác minh; nếu bạn triển khai lên một chuỗi mới và việc xác minh هنوز chưa tìm thấy nó, hãy chờ một lúc hoặc liên hệ.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rome.builders/vi/huong-dan-cho-nha-phat-trien/verify-contracts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
