> 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/tips-and-tricks.md).

# เคล็ดลับและเทคนิค

เคล็ดลับสำหรับนักพัฒนา Chiliz Chain: สร้าง ERC-20 test token ได้ไม่จำกัดบน Spicy Testnet, ดึงราคา gas ปัจจุบันผ่าน RPC และวิธีแก้ไขข้อจำกัดรายวันของ faucet

## วิธีสร้าง token ของคุณเองบน Spicy Testnet

การพัฒนาแอปบน Chiliz Chain Mainnet จำเป็นต้องทดสอบบน Spicy Testnet ก่อน เพื่อตรวจสอบว่าโค้ดของคุณจัดการกับ testCHZ token ได้ถูกต้อง โดยไม่ต้องใช้ CHZ token จำนวนมากที่มีค่าใช้จ่ายสูง สำหรับจุดประสงค์นี้ คุณสามารถรับ Testnet token ได้ฟรีผ่าน Spicy Faucet ของเรา:

{% content-ref url="/pages/y7HDC2TBdwvv53pjrCSt" %}
[รับ Token Testnet ฟรี](/th/phatthana/phuenthan/rap-token-testnet.md)
{% endcontent-ref %}

แต่บางครั้งการพัฒนาต้องใช้ test token จำนวนมาก และ faucet มีข้อจำกัดในจำนวน token ที่คุณสามารถรับได้ในแต่ละวัน

เพื่อให้คุณหลุดพ้นจากข้อจำกัดนี้ คุณสามารถสร้าง token ของคุณเองบน Spicy Testnet ได้! Chiliz Chain (ทั้ง Mainnet และ Testnet) เป็น EVM-compatible chain และ CHZ กับ testCHZ token นั้นแท้จริงแล้วเป็น ERC20 token

ดังนั้นคุณสามารถ mint ERC20 token ของคุณเองแบบแทบไม่จำกัดบน Spicy Testnet และทดสอบโค้ดของคุณอย่างละเอียดกับ token นั้น จากนั้นเมื่อคุณรู้สึกว่าพร้อมแล้ว ให้ทดสอบ dApp ของคุณด้วย test CHZ token บน Spicy อีกสองสามครั้งก่อนจะเปิดตัวบน Chiliz Chain Mainnet

นี่คือขั้นตอนในการสร้าง token ของคุณเองบน Spicy Testnet:

1. [เชื่อมต่อ MetaMask กับ Chiliz Spicy Testnet](/th/riang-ru/krapao-ngoen/metamask/liangk-metamask.md)
2. [รับ test CHZ token จาก Spicy Faucet](/th/phatthana/phuenthan/rap-token-testnet.md) ขั้นตอนนี้จำเป็นเพราะคุณต้องใช้ CHZ token เพื่อ deploy smart contract ERC20 ของคุณ
3. เขียน smart contract ของ token (เราแนะนำให้ใช้ [OpenZeppelin's ERC20](https://docs.openzeppelin.com/contracts/5.x/erc20)) ใน `constructor` ของคุณ ให้กำหนดชื่อของ token (เช่น "MyOwnToken"), symbol (เช่น "MOT") และ mint จำนวนเริ่มต้นที่เพียงพอสำหรับความต้องการของคุณ
4. [คอมไพล์ smart contract และ deploy ไปยัง Spicy Testnet](/th/phatthana/phuenthan/deploy-smart-contract.md) จากนั้นยืนยันผ่าน [block explorer](/th/phatthana/phuenthan/chai-block-explorer.md)
5. ดู token ใหม่ของคุณใน MetaMask:
   1. คัดลอกที่อยู่ smart contract ของ token จากเครื่องมือ deploy ของคุณ (เช่น เมนู "Deployed Contracts" ของ Remix)
   2. ใน MetaMask ไปที่แท็บ "Tokens" และคลิก "Import tokens"
   3. วางที่อยู่ smart contract โดย symbol และ decimals จะกรอกอัตโนมัติ
   4. คลิก "Add custom token" จากนั้น "Import tokens" ตอนนี้คุณควรเห็นยอดคงเหลือของ token ใหม่ของคุณ

ตอนนี้คุณพร้อมที่จะทดสอบ Chiliz Chain dApp ของคุณบน Spicy Testnet ด้วย token ของคุณเองแล้ว!

## วิธีดึงราคา gas ปัจจุบัน

หากต้องการดูราคา gas บน Chiliz Chain คุณสามารถใช้ [public RPC node หนึ่งในนั้น](https://docs.chiliz.com/develop/connect-to-chiliz-chain/connect-using-rpc)

คุณสามารถดึงราคา gas ปัจจุบันได้ดังนี้:

```bash
curl --location 'https://rpc.ankr.com/chiliz' # For Spicy: https://spicy-rpc.chiliz.com/
--header 'Content-Type: application/json' 
--data '{ 
    "method": "eth_gasPrice", 
    "params": [], 
    "id": 1, 
    "jsonrpc": "2.0"
}'
```

## วิธีตรวจสอบสาเหตุที่ธุรกรรมล้มเหลว

ธุรกรรมอาจล้มเหลว และคุณไม่ทราบสาเหตุเสมอไป โดยเฉพาะอย่างยิ่งเมื่อ block explorer ไม่แสดงข้อผิดพลาด

{% hint style="warning" %}
เพื่อให้แน่ใจว่าธุรกรรมของคุณจะไม่อยู่ในสถานะ "pending" นานเกินไป คุณควรรวมค่าธรรมเนียมให้เพียงพอ:

* ค่า gas ขั้นต่ำ: 2,501 Gwei
* ค่า priority fee ขั้นต่ำ: 1 Gwei
  {% endhint %}

หากต้องการตรวจสอบสาเหตุที่ธุรกรรมของคุณล้มเหลว ให้รันสคริปต์ต่อไปนี้ใน terminal โดยใส่ transaction ID ที่ถูกต้อง:

```bash
curl --location 'https://rpc.ankr.com/chiliz' # For Spicy: https://spicy-rpc.chiliz.com/
--header 'Content-Type: application/json' 
--data '{
    "method": "debug_traceTransaction",
    "params": [
        "[Transaction ID]",
        {
            "tracer": "callTracer"
        }
    ],
    "id": 1,
    "jsonrpc": "2.0"
}'
```


---

# 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/tips-and-tricks.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.
