> For the complete documentation index, see [llms.txt](https://flare-community-lucky-claw.gitbook.io/get-started/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://flare-community-lucky-claw.gitbook.io/get-started/fiarness/technicals.md).

# Technicals

{% hint style="success" %}
Promoting fairness and transparency with verifiable on-chain data!
{% endhint %}

Let's first break down how the monthly draw will happen from a technical perspective. Starting with the fact it will be facilitated with the following 2 items:

* Local Program (JavaScript)
* <mark style="color:purple;">Lucky Claw Smart Contract (Solidity)</mark>

Each month a lucky winner will be drawn using these two programs which will communicate with each other, here is the basic workflow / process:

<figure><img src="/files/0nD07EHK5kHbcjwV1AgO" alt=""><figcaption></figcaption></figure>

In addition to helping automate / streamline the drawing process (by interacting with the smart contract, selecting / opening the winning animation / navigating to the winning NFT), the local program will be used to inject a random number into the smart contract. Before we jump into why this is important, we first need to understand an attribute of the Ethereum Virtual Machine.

{% hint style="info" %}
The Ethereum Virtual Machine (EVM) is deterministic system.
{% endhint %}

> In mathematics, computer science and physics, a deterministic system is a system in which no randomness is involved in the development of future states of the system. A deterministic model will thus always produce the same output from a given starting condition or initial state.

This means, creating a truly random number, on-chain, is actually impossible. Instead we have to settle for a pseudo-random number, created by combining a number of network variables such as block height and gas limit. This will be made truly random by inputting an off-chain variable as a parameter.\
\
As the Flare Network creates blocks every 1-2 seconds and the fact that the gas height changes frequently (depending on the demand of the network), these two variables are a great starting point for randomness.

In order to achieve true randomness we need to bring data off-chain, into the smart contract.&#x20;

```javascript
Math.Random();
```

The numbers (in a basic sense) are used to generate a very large number, subsequently the modulo operator (%) is used to output a minimum and maximum range (which will be 1 and the amount of NFTs minted).

```solidity
// Generate a random number and set the view state to hidden.
function generateRandomNumber(uint256 input) public onlyOwner {
    // Enter stealth mode
    hidden = true;
    // Set (current) mint amount
    mintAmount = ILuckyClaw(luckyClawAddress).totalSupply();
    // Generate a large random number
    uint256 random = uint256(keccak256(abi.encodePacked(block.difficulty, block.timestamp, block.gaslimit))) + input;
    // Rescale it to a number between 1 and the FCLC mintAmount
    randomNumber = random % mintAmount + 1;
}
```

The code snippet above comes from the publicly available smart contract deployed on the Flare Network, you can find it [**here**](https://flare-explorer.flare.network/address/0x5C672D7AF4B42a3c571d18436B96452Bf16b8150/contracts#address-tabs).
