# Using the random beacon on-chain

Follow this tutorial to learn how to write a smart contract that consumes randomness from Cryptosat's Random Beacon contract.

### Create and deploy Sample contract[​](broken://pages/d2GeunwLZeXqezJwUt7G) <a href="#create-and-deploy-contract" id="create-and-deploy-contract"></a>

In this example, we use the example client contract that is available on our Github repository- [ClientContract.sol](https://remix.ethereum.org/#url=https://raw.githubusercontent.com/cryptosat/randomness/main/contracts/ClientContract.sol)

1. Open [`ClientContract.sol` in Remix](https://remix.ethereum.org/#url=https://raw.githubusercontent.com/cryptosat/randomness/main/contracts/ClientContract.sol)
2. Go to the compiler tab, as shown below:<br>

   <div align="left"><figure><img src="/files/6CzeA7qwl1oWFpYPMqNY" alt=""><figcaption></figcaption></figure></div>
3. Compile `ClientContract.sol`
4. Deploy your new contract that consumes our Random Beacon contract:&#x20;
   1. Click the Deploy & run transactions tab
   2. In the Environment drop-down menu, choose "Injected Provider - MetaMask". Don't forget to approve in the pop-up.
   3. Next to the Deploy button, enter the address of the random beacon:

* Velas Mainnet: `0x8f5FE77380B83BaA7365ccc9956EB0594859F9E4`
* Velas Testnet: `0x4a301BBC5D999C2AAfa01E299C46C654dA6C0fF7`

In this example, we'll use the Testnet address:

![](/files/5qYnGjITai9Lf2xa4WFd)<br>

After you deploy your contract, you can interact with it.

Click on the `requestRandomWord` button to request Space Random Beacon.\
\
![](/files/8uaC2zk7TJTtwrfBA6xe)<br>

Your request has now been queued and will be submitted to the satellite. The request can take several hours to return to complete.&#x20;

Once the random number is generated, you can view it by clicking on the `random` button.

\
![](/files/QxMjZuGm6wvHjTc5EmBp)


---

# 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.cryptosat.io/cryptosat/random-beacon/using-the-random-beacon-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.
