> 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/develop/advanced/generate-random-numbers-on-chain.md).

# Generate random numbers on-chain

Generate cryptographically secure random numbers on Chiliz Chain using Pyth Entropy (ideal for NFT mints, gaming mechanics, and prediction markets).

True randomness is a hard topic in computer science, and it is difficult to achieve all by yourself. When randomness is key to your project, we advise you to use a reputed Random Number Generator (RNG).

## What is an RNG?

By producing sequences of numbers that cannot be predicted, RNGs ensure fairness and uniqueness in blockchain projects. This enhances the integrity and trustworthiness by preventing manipulation and ensuring equitable results.

## What does it mean for Chiliz Chain developers

By incorporating RNGs, sports & entertainment projects can significantly boost the trust, excitement, and fairness of what they offer.

## How to do it using Pyth?

Chiliz Chain supports Pyth's Entropy.

Entropy allows developers to quickly and easily generate random numbers on the blockchain for applications such as NFT mints, gaming, and more.\
Through the Solidity SDK, this enables developers to easily integrate RNG into their EVM applications.

{% hint style="info" %}
Use the following address to use Entropy using Chiliz.

#### On Chiliz Mainnet

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

#### On Spicy Testnet

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

Pyth offers a full set of [documentation on Entropy](https://docs.pyth.network/entropy), including:

* [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 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/develop/advanced/generate-random-numbers-on-chain.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.
