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.
- Deploy your consumer with the Randoo coordinator
0xC66eB2e7EE91145875000Ad46B55600000000001(same CREATE3 address on Ronin mainnet and Saigon). - Call
estimateRequestRandomFee(callbackGasLimit, gasPrice). - Call
requestRandomSeedwithmsg.value >= estimateand a non-zero refund address (not the consumer if it is not payable). - The oracle fulfills. Your
rawFulfillRandomSeedruns 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;
}
}