Select Chain

Orakururu

Off-chain Data oracle services made easy by Kururu~

Random number
More coming...

Random number oracle

Provide your smart contract with random number data

Example use cases


  • • Lottery draw result
  • • Casino game
  • • RNG-Based game mechanic ex. ATK damage, Proc Critical Hit

How it work


Random

Getting Start


Contract Address ()

Example Contract


pragma solidity ^0.8.0;

interface IKururuGuru {
	function request() external returns (uint256);
	function kuru() external returns (address);
}

interface IApprove {
	function approve(address spender, uint256 amount) external returns (bool);
}

contract KururuGuruConsumer {
	function guru(uint256 requestId, uint256 number) internal virtual {}

	address public kururuGuru;

	constructor(address kururuGuru_) {
		kururuGuru = kururuGuru_;
		address kuru = IKururuGuru(kururuGuru_).kuru();
		IApprove(kuru).approve(kururuGuru_, type(uint256).max);
	}

	function requestGuru() internal returns (uint256) {
		return IKururuGuru(kururuGuru).request();
	}

	function fulfillGuru(uint256 id, uint256 number) external {
		require(msg.sender == kururuGuru, "!guru");
		guru(id, number);
	}
}

contract KururuGuruExample is KururuGuruConsumer {
	event Rolled(address indexed sender, uint256 id);

	constructor(address guruAddr) KururuGuruConsumer(guruAddr) {}

	struct Roll {
		address roller;
		uint256 result;
		bool rolled;
	}

	Roll[] public rolls;
	mapping (uint256 => uint256) internal guruToRoll;

	function guru(uint256 requestId, uint256 number) internal override {
		uint256 rollIndex = guruToRoll[requestId];
		require(!rolls[rollIndex].rolled, "rolled");
		rolls[rollIndex].result = number % 100;
		rolls[rollIndex].rolled = true;
	}

	function roll() external returns (uint256) {
		uint256 requestId = requestGuru();
		uint256 rollIndex = rolls.length;
		rolls.push(Roll(
			msg.sender,
			0,
			false
		));
		guruToRoll[requestId] = rollIndex;
		emit Rolled(msg.sender, rollIndex);
		return rollIndex;
	}
}

Error