> 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/sung-khuen/on-chain-random-numbers.md).

# สร้างตัวเลขสุ่มบน on-chain

ความสุ่มที่แท้จริงเป็นหัวข้อที่ยากในสาขาวิทยาการคอมพิวเตอร์ และเป็นเรื่องยากที่จะทำได้ด้วยตัวเองทั้งหมด เมื่อความสุ่มเป็นหัวใจสำคัญของโปรเจกต์ของคุณ เราขอแนะนำให้คุณใช้ Random Number Generator (RNG) ที่มีชื่อเสียง

## RNG คืออะไร?

ด้วยการสร้างลำดับของตัวเลขที่ไม่สามารถคาดเดาได้ RNG จึงช่วยรับประกันความยุติธรรมและความไม่ซ้ำใครในโปรเจกต์ blockchain สิ่งนี้เสริมสร้างความสมบูรณ์และความน่าเชื่อถือ โดยป้องกันการปั่นแต่งและรับประกันผลลัพธ์ที่เท่าเทียมกัน

## มีความหมายอย่างไรสำหรับนักพัฒนา Chiliz Chain?

ด้วยการนำ RNG มาใช้ โปรเจกต์ด้านกีฬาและความบันเทิงสามารถเพิ่มความไว้วางใจ ความตื่นเต้น และความยุติธรรมของสิ่งที่พวกเขานำเสนอได้อย่างมีนัยสำคัญ

## ทำอย่างไรด้วย Pyth?

Chiliz Chain รองรับ Entropy ของ Pyth

Entropy ช่วยให้นักพัฒนาสามารถสร้างตัวเลขสุ่มบน blockchain ได้อย่างรวดเร็วและง่ายดายสำหรับแอปพลิเคชันต่าง ๆ เช่น การ mint NFT, เกม และอื่น ๆ อีกมากมาย\
ผ่าน Solidity SDK สิ่งนี้ช่วยให้นักพัฒนาสามารถรวม RNG เข้ากับแอปพลิเคชัน EVM ของตนได้อย่างง่ายดาย

{% hint style="info" %}
ใช้ที่อยู่ต่อไปนี้เพื่อใช้งาน Entropy บน Chiliz

#### บน Chiliz Mainnet

* Chain ID:\
  `chiliz`
* Entropy Contract Address:\
  `0x0708325268dF9F66270F1401206434524814508b`
* Provider:\
  `0x52DeaA1c84233F7bb8C8A45baeDE41091c616506`<br>

#### บน Spicy Testnet

* Chain ID:\
  `chiliz-spicy`
* Entropy Contract Address:\
  `0xD458261E832415CFd3BAE5E416FdF3230ce6F134`
* Provider:\
  `0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344`
  {% endhint %}

Pyth มี[เอกสารประกอบเกี่ยวกับ Entropy](https://docs.pyth.network/entropy)อย่างครบถ้วน ซึ่งรวมถึง:

* [Create your first Entropy app on EVM](https://docs.pyth.network/entropy/create-your-first-entropy-app)
* [How to Generate Random Numbers in EVM Contracts Using Pyth Entropy](https://docs.pyth.network/entropy/generate-random-numbers/evm)
* [A sample application demonstrating how to use Pyth Entropy to flip a fair coin](https://github.com/pyth-network/pyth-crosschain/blob/main/target_chains/ethereum/examples/coin_flip/contract/src/CoinFlip.sol).


---

# 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 dynamically by asking a question.

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

```
GET https://docs.chiliz.com/th/phatthana/sung-khuen/on-chain-random-numbers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
