Scry Protocol
  • Introduction
  • Morpheus
    • Morpheus
    • Build Your Own Oracle
    • Contract Use and Request Feeds
      • VRF
      • Crosschain Data
      • Jury - Human Defined Questions
    • Sample Templates for Contracts
    • MetaMorph: A Decentralized Oracle Tool
    • VRF Hash RanCh
    • Deployments and Oracles Available
    • Veryfi - cross-chain asset verification
  • Vain
    • Deep dive
  • Scry Token and Staking $SCRY
    • The $SCRY Token: A New Age in Oracle Collateralization and Decentralization
    • Staking
    • Distribution
  • Open Oracle Framework
    • Subscription Based Models
    • Data Feeds for Historical Tracking
    • Time Weighted Average Price using OOF
    • Feed Requests
    • Oracle Spreadsheet Management and Creation
    • Oracle Creation
    • Oracle Management
    • Front End
    • Solidity Contracts and Interface
    • OpenOracleFramework.sol
    • OOFFactory.sol
    • Deployments
  • SMART CONTRACTS
    • Smart Contracts
  • Links
    • Links
    • Deprecated
      • Purchasing a License
      • Licensing and Perks
      • Scry NFT
Powered by GitBook
On this page
  1. Morpheus
  2. Contract Use and Request Feeds

VRF

PreviousContract Use and Request FeedsNextCrosschain Data

Last updated 1 year ago

To request a Verifiable Random Function (VRF) feed, use the requestFeeds function with 'vrf' as the endpoint. Optionally, include a unique identifier or "salt" in the APIendpointpath to ensure each VRF, preventing potential influence by the oracle. The oracle will return the VRF as a 256-bit unsigned integer (uint256). Note that each request generates a unique feed ID, so for each new VRF, a separate requestFeeds call is required. More info in

Sample

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface Morpheus {
    function getFeed(
        uint256 feedID
    )
        external
        view
        returns (
            uint256 value,
            uint256 decimals,
            uint256 timestamp,
            string memory valStr
        );

    function requestFeeds(
        string[] calldata APIendpoint,
        string[] calldata APIendpointPath,
        uint256[] calldata decimals,
        uint256[] calldata bounties
    ) external payable returns (uint256[] memory feeds);
}

contract VRF{
    Morpheus public morpheus;
    uint vrfID;
    uint oracleFee = 100000000000000;
    address winner;
    address player;
    constructor() {
        morpheus = Morpheus(0x0000000000071821e8033345A7Be174647bE0706);
    }

    function play() public{
     require(msg.value>=oracleFee);
    require(player==address(0));
   player=msg.sender;
     requestVRF();
    }


    function requestVRF() internal {
        string[] memory apiEndpoint = new string[](1);
        apiEndpoint[0] = "vrf";
        string[] memory apiEndpointPath = new string[](1);
        apiEndpointPath[0] = "";
        uint256[] memory decimals = new uint256[](1);
        decimals[0] = 0;
        uint256[] memory bounties = new uint256[](1);
        bounties[0] = oracleFee ;
        uint256[] memory feeds = morpheus.requestFeeds{value: oracleFee }(
            apiEndpoint,
            apiEndpointPath,
            decimals,
            bounties
        );
    vrfID= feeds[0];
    }

    function determineWinner() public {
        require(
            vrfID!=0
        );
        (uint256 vrfValue, , , ) = morpheus.getFeed(vrfID);
        require(vrfValue != 0, "Oracle not ready");
        uint256 roll = (vrfValue % 100) + 1;
        if (roll>51){winner=player;}
        player=address(0);
    }
}

See for more info

VRF Hash RanCh
https://docs.scry.finance/docs/morpheus/vrf-hash-ranch