> For the complete documentation index, see [llms.txt](https://docs.chiliz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chiliz.com/th/phatthana/phuenthan/verify-smart-contract/best-practices.md).

# แนวทางปฏิบัติที่ดีในการ Verify

แนวปฏิบัติที่ดีที่สุดสำหรับการยืนยัน contract บน Chiliz Chain: รายละเอียด CAP-20 token, การตั้งค่าเวอร์ชัน Solidity และ EVM ที่แนะนำ, และข้อผิดพลาดทั่วไปจากโค้ดที่เขียนสำหรับ Ethereum

การยืนยัน smart contract บน Chiliz Chain ต้องอาศัยทั้งแนวปฏิบัติมาตรฐาน EVM และความใส่ใจต่อรายละเอียดเฉพาะของ chain

เนื่องจาก Chiliz Chain ทำงานบนกลไกฉันทามติ Proof of Staked Authority (PoSA) พร้อมมาตรฐานเฉพาะอย่าง CAP-20 และการกำหนดเวอร์ชัน EVM แบบเฉพาะของตัวเอง การนำโค้ดจาก Ethereum มาใช้โดยตรงอาจไม่ได้ผลเสมอไป

## ทำความเข้าใจมาตรฐาน CAP-20

แม้ Chiliz Chain จะรองรับ EVM แต่ระบบนิเวศนี้ใช้มาตรฐาน CAP-20 สำหรับ token ซึ่งเป็นการนำ ERC-20 มาปรับใช้เฉพาะสำหรับ Chiliz

ดูรายละเอียด token ได้ที่นี่:

{% content-ref url="/pages/2aljCUr6tADH7xd6N2QV" %}
[CAP-20](https://docs.chiliz.com/th/riang-ru/glossary/cap-20.md)
{% endcontent-ref %}

หากคุณกำลังพัฒนา Fan Token หรือ asset ที่ต้องการให้ทำงานเหมือน Fan Token ให้กำหนด decimals เป็น 18 ซึ่งตรงกับมาตรฐาน CAP-20 นับตั้งแต่การย้ายระบบ Decimal Fan Token ปี 2026

{% hint style="info" %}
Fan Tokens ใช้ 0 decimals จนกระทั่งเกิด[การย้ายระบบปี 2026 สู่ Decimal Fan Tokens](https://docs.chiliz.com/th/riang-ru/fan-tokens/yai-2026.md) ซึ่งได้อัปเกรดให้มีความแม่นยำ 18 decimals กำหนดสัญญา Fan Token ใหม่ให้ใช้ 18 decimals
{% endhint %}

## กำหนดค่า compiler และ EVM

validator ของ Chiliz Chain ได้รับการปรับแต่งให้เหมาะสมกับเวอร์ชัน EVM เฉพาะ การใช้การตั้งค่าที่ใหม่เกินไปอาจทำให้เกิดความล้มเหลวในการปรับใช้หรือพฤติกรรมที่ไม่คาดคิด

คุณควรใช้เวอร์ชันเหล่านี้:

{% hint style="info" %}
**เวอร์ชัน Solidity และ EVM ที่แนะนำสำหรับ Chiliz Chain:**

* **เวอร์ชัน Solidity compiler:** `0.8.30` (หรือต่ำกว่า)
* **เวอร์ชัน EVM เป้าหมาย:** `prague`
  {% endhint %}

## ปรับแต่งเพื่อประหยัด gas

Chiliz Chain กำหนดราคา gas ขั้นต่ำแบบ "high-Gwei" เพื่อป้องกัน spam และรับประกันความยั่งยืนของ validator

นับตั้งแต่ Dragon8 hard fork, Chiliz Chain ใช้งาน EIP-1559 แต่มี **ค่า base fee ขั้นต่ำที่ 2500 gwei** ซึ่งหมายความว่าโค้ดที่ไม่ได้รับการปรับแต่งจะมีค่าใช้จ่ายสูงกว่า chain อื่นมากสำหรับผู้ใช้ของคุณ

ดังนั้น คุณควรปรับแต่ง contract ให้ใช้ storage อย่างมีประสิทธิภาพ (ซึ่งเป็นการดำเนินการที่แพงที่สุด):

* จัดกลุ่มตัวแปร `uint128`, `uint64` หรือ `bool` ไว้ติดกันเพื่อให้พอดีกับ storage slot ขนาด 32 bytes เดียว
* ใช้ `calldata` แทน `memory` สำหรับอาร์กิวเมนต์ของฟังก์ชันแบบอ่านอย่างเดียว (external functions) เพื่อประหยัด gas ระหว่างการดำเนินการ

{% hint style="success" %}
ติดตั้ง `hardhat-gas-reporter` และกำหนดค่าด้วยการตั้งค่าราคา gas เฉพาะของ Chiliz เพื่อดูต้นทุนจริงในหน่วย CHZ ก่อนที่คุณจะปรับใช้
{% endhint %}

## ทดสอบบน Spicy เสมอ

อย่าสันนิษฐานว่า Mainnet จะทำงานเหมือนกันโดยอิงจากประสบการณ์ Ethereum ของคุณ คุณต้องทดสอบการทำงานร่วมกับ Chiliz PoSA consensus บน Spicy Testnet ก่อนที่จะย้ายไปยัง Chiliz Chain Mainnet

ดูรายละเอียดการเชื่อมต่อได้ที่นี่:

{% content-ref url="/pages/dQdErvu9eh3NWFvwbVSA" %}
[เชื่อมต่อกับ Chiliz Chain](https://docs.chiliz.com/th/phatthana/phuenthan/tho-chiliz-chain.md)
{% endcontent-ref %}


---

# 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.chiliz.com/th/phatthana/phuenthan/verify-smart-contract/best-practices.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.
