🀞
FC Lucky Claw - Complete Guide
  • πŸ’ŽFlare Community Lucky Claw!
  • The Basics
    • 🎁Prize Pool
    • πŸ€‘Upcoming Jackpots!
    • πŸ—ΊοΈEcosystem Map
    • πŸ—“οΈSchedule
    • ❓FAQ
  • Sponsorship
    • πŸ”₯Overview
  • πŸ’°Holder Benefits
  • 🀝Project Benefits
  • πŸ“ˆEXPANSION
    • πŸ”₯Overview
  • πŸ”„Compounding Value
  • πŸ—³οΈGovernance
  • πŸͺ™FC Coin
  • πŸ’ΈRoyalty Share
  • Fiarness
    • πŸ‘€Transparency
    • βœ…Validation Overview
    • πŸ’ͺTechnicals
    • β˜‘οΈDraw History
  • Contact
    • πŸ“…Book a Meeting
  • Sponsors
    • πŸ”₯FTSO AU
    • 🦩FlareMingos!
    • πŸŽ“Uppercent!
    • πŸ’The Mandrills
Powered by GitBook
On this page
  1. Fiarness

Technicals

PreviousValidation OverviewNextDraw History

Last updated 2 years ago

Promoting fairness and transparency with verifiable on-chain data!

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)

  • Lucky Claw Smart Contract (Solidity)

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

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.

The Ethereum Virtual Machine (EVM) is deterministic system.

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.

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).

// 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
πŸ’ͺ
Page cover image