# Generate random numbers on-chain

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: 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:

```
GET https://docs.chiliz.com/develop/advanced/generate-random-numbers-on-chain.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
