Skip to content

Quickstart

Randoo is pay-per-request on Ronin. Inherit VRFConsumer from the Ronin random beacon, quote the fee on-chain, and send it with the request.

  1. Deploy your consumer with the Randoo coordinator 0xC66eB2e7EE91145875000Ad46B55600000000001 (same CREATE3 address on Ronin mainnet and Saigon).
  2. Call estimateRequestRandomFee(callbackGasLimit, gasPrice).
  3. Call requestRandomSeed with msg.value >= estimate and a non-zero refund address (not the consumer if it is not payable).
  4. The oracle fulfills. Your rawFulfillRandomSeed runs with the seed.
Consumer · Ronin ABI
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {VRFConsumer} from "@ronin-chain/ronin-random-beacon/contracts/consumer/VRFConsumer.sol";

contract LootBox is VRFConsumer {
    uint256 public lastSeed;

    constructor(address _vrfCoordinator) VRFConsumer(_vrfCoordinator) {}

    function roll() external payable returns (bytes32 reqHash) {
        reqHash = _requestRandomness(
            msg.value,
            250_000,
            20e9 + block.basefee * 2,
            msg.sender
        );
    }

    function _fulfillRandomSeed(
        bytes32 /* reqHash */,
        uint256 randomSeed
    ) internal override {
        lastSeed = randomSeed;
    }
}