> 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ụ [Sourcify](https://sourcify.dev) xác minh được lưu trữ. Sau khi xác minh hợp đồng, mã nguồn và ABI của hợp đồng sẽ có thể được tái tạo công khai và hiển thị cùng huy hiệu **✓ Đã xác minh mã nguồn** trên trình khám phá khối Rome (Via).

Quy trình xác minh tương thích với các cách dùng tiêu chuẩn của `forge verify-contract` và `hardhat-verify` — bạn chỉ cần trỏ chúng đến trình xác minh của Rome.

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

| Môi trường        | URL trình xác minh                        |
| ----------------- | ----------------------------------------- |
| Testnet và 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ờ tiêu chuẩn `--chain-id` .

## Foundry

Sau khi triển khai (xem [Triển khai hợp đồng Solidity](https://docs.rome.builders/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 hàm tạo nhận tham số, hãy truyền các tham số đó để bytecode khớp nhau:

```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 tự suy ra ID chuỗi từ `--rpc-url`).

## Hardhat

`hardhat-verify` được tích hợp trong bộ công cụ Hardhat 3. Trỏ nhà cung cấp Sourcify của công cụ này đến trình xác minh của Rome trong `hardhat.config.ts` rồi chạy `hardhat verify`:

```typescript
export default defineConfig({
  // …plugins, solidity, networks…
  verify: {
    etherscan: { enabled: false },
    blockscout: { enabled: false },
    sourcify: {
      enabled: true,
      apiUrl: "https://verify.testnet.romeprotocol.xyz",   // Rubicon mainnet: "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>
```

Hợp đồng đã xác minh sẽ trả về trường `match`  như sau:

* **`exact_match`** — bytecode *và* hàm băm siêu dữ liệu trùng khớp (khớp "toàn phần" hoàn hảo).
* **`match`** — bytecode trùng khớp; siêu dữ liệu hơi khác (vẫn là một kết quả khớp hợp lệ đã được xác minh).
* `404` / `null` — chưa được xác minh.

## Lưu ý

* Các hợp đồng được xác minh trên trình xác minh của Rome sẽ hiển thị tên hợp đồng trong Rome Via (trình khám phá).
* Với proxy có thể nâng cấp, hãy xác minh cả phần triển khai lẫn proxy.
* Để xác minh, bạn chỉ cần bytecode đã triển khai của hợp đồng cùng mã nguồn và các thiết lập trình biên dịch bạn gửi — giống như các dữ liệu đầu vào trên mọi chuỗi EVM.
* Các chuỗi Rome mới đượ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 mà trình xác minh chưa tìm thấy, hãy đợi một lúc hoặc liên hệ với chúng tôi.


---

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