Skip to content

The 10% of the OVR tokens realized from OVRLand monthly sale is being distributed to lucky OVRLand owners who bought OVRLand during each month under consideration. Ten (10) lucky winners are being randomly selected using the Chainlink’s VRF every month. However, it is important to note that in every succeeding extraction we remove the OVRLands o…

Notifications You must be signed in to change notification settings

OVR-Platform/ovrland-monthly-chainlink-extractions

Repository files navigation

OVRLand Monthly ChainLink Extraction

To view the results on Polygonscan click on "Read Contract" and scroll down to tab number 5 "Result" and enter the draw number.

Smart Contract Source Code

Randomness is very difficult to generate on blockchains. The reason for this is because every node must come to the same conclusion, forming a consensus. There's no way to generate random numbers natively in smart contracts, which is unfortunate because they can be very useful for a wide range of applications.

Chainlink VRF (Verifiable Random Function) is a provably-fair and verifiable source of randomness designed for smart contracts. Smart contract developers can use Chainlink VRF as a tamper-proof RNG to build reliable smart contracts for any applications which rely on unpredictable outcomes:

  • Blockchain games and NFTs
  • Random assignment of duties and resources (e.g. randomly assigning judges to cases)
  • Choosing a representative sample for consensus mechanisms

Chainlink VRF enables smart contracts to access randomness without compromising on security or usability. With every new request for randomness, Chainlink VRF generates a random number and cryptographic proof of how that number was determined. The proof is published and verified on-chain before it can be used by any consuming applications. This process ensures that the results cannot be tampered with nor manipulated by anyone, including oracle operators, miners, users and even smart contract developers.

Here how OVR uses Chainlink VRFConsumerBase Contract:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;

import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract RandomWinner is VRFConsumerBase, Ownable {
    bytes32 internal keyHash;
    uint256 internal fee;
    uint256 public id = 0;

    mapping(uint256 => uint256) public partecipants;
    mapping(uint256 => uint256) public draw;

    /**
     * Constructor inherits VRFConsumerBase
     *
     * Network: Polygon Mainnet
     * Chainlink VRF Coordinator address: 0x3d2341ADb2D31f1c5530cDC622016af293177AE0
     * LINK token address:                0xb0897686c545045aFc77CF20eC7A532E3120E0F1
     * Key Hash: 0xf86195cf7690c55907b2b611ebb7343a6f649bff128701cc542f0569e2c549da
     */
    constructor()
        VRFConsumerBase(
            0x3d2341ADb2D31f1c5530cDC622016af293177AE0, // VRF Coordinator
            0xb0897686c545045aFc77CF20eC7A532E3120E0F1 // LINK Token
        )
    {
        keyHash = 0xf86195cf7690c55907b2b611ebb7343a6f649bff128701cc542f0569e2c549da;
        fee = 0.0001 * 10**18; // 0.0001 LINK (Varies by network)
    }

    function setPartecipants(uint256 _partecipants) internal {
        partecipants[id] = _partecipants;
    }

    function results(uint256 _id)
        public
        view
        returns (uint256 _winner, uint256 _partecipants)
    {
        return (draw[_id], partecipants[_id]);
    }

    /**
     * Requests randomness
     */
    function getRandomNumber(uint256 _partecipants)
        public
        onlyOwner
        returns (bytes32 requested)
    {
        setPartecipants(_partecipants);
        require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK");
        return requestRandomness(keyHash, fee);
    }

    /**
     * Callback function used by VRF Coordinator
     */
    function fulfillRandomness(bytes32 requestId, uint256 randomness)
        internal
        override
    {
        draw[id] = (randomness % partecipants[id]) + 1;
        id++;
    }
}

About

The 10% of the OVR tokens realized from OVRLand monthly sale is being distributed to lucky OVRLand owners who bought OVRLand during each month under consideration. Ten (10) lucky winners are being randomly selected using the Chainlink’s VRF every month. However, it is important to note that in every succeeding extraction we remove the OVRLands o…

Topics

Resources

Stars

Watchers

Forks