🌋
Obelisk
  • Getting Started
  • V0
    • Guides
      • Get Papyrus NFTs
      • Enter Draws
      • Rounds
      • Withdraw Yield
    • Liquid Staking
      • Pirex ETH
    • Donation
    • Fees & Treasury
  • Development
    • Contributing
    • Audits
    • V0 Contracts
      • Obelisk
      • YieldHubPirexEth
      • RNGSender
      • Papyrus
Powered by GitBook
On this page
  • Overview
  • Random Number Generation
  • Randomizer Fee
  • LayerZero Messaging
  • LayerZero Fee
  1. Development
  2. V0 Contracts

RNGSender

RNGSender's main job is to send random numbers generated in Arbitrum to a chain where Obelisk exists.

PreviousYieldHubPirexEthNextPapyrus

Last updated 1 year ago

Overview

The RNGSender contract is designed to be deployed on the Arbitrum network. It serves as a random number sender generated from the Randomizer.ai. The contract requests random numbers by providing a slug and paying a fee to Randomizer.ai. Once the random number is generated from Randomizer.ai, it can be sent to Obelisk on another chain using the LayerZero protocol via the RNGSender. All these processes are fundamentally automated, and in case of any issues preventing automatic execution, the owner has the ability to manually intervene and resolve them.

Random Number Generation

If RNGSender.request() was called with proper arguments, after a period of confirmations, RNGSender.randomizerCallback() is triggered by Randomizer protocol with the number generated included as a parameter. The number has a range from 0 to type(uint256).max.

Randomizer Fee

To use Randomizer's RNG, a certain amount of ETH fee needs to be paid and that amount is transferred from RNGSender contract. The value is calculated via RNGSender.estimateRandomizerFee().

LayerZero Messaging

Automatic transfer meaning, inside RNGSender.randomizerCallback(), it calls RNGSender.sendValue() as an external call automatically but it could fail due to various reasons (ex. insufficient gas, relaying issues, etc). In that case, owner can call sendValue() with proper arguments in a right timing.

LayerZero Fee

Just like how Randomizer works, to use LayerZero messaging, a certain amount of ETH fee needs to be paid and that amount is transferred from RNGSender contract. The value is calculated via RNGSender.estimateLayerZeroFee().

Random numbers are generated by , a decentralized and on-chain RNG protocol. It requires ETH to be settled for random numbers to be generated and it's been deployed Arbitrum mainnet only so far. That's the reasoning behind RNGSender being deployed to Arbitrum.

Actually RNGSender.request() is called automatically when a LayerZero message arrives from contract on another chain. Only when that fails, owner can call it manually with proper arguments.

Since the value is paid from RNGSender contract, ETH amount needs to have been stored in the contract, it was transferred from or it can be paid when calling RNGSender.request().

For more info, refer to .

After a random number is generated, it needs to be transferred back to contract automatically or by calling RNGSender.sendValue().

Since the value is paid from RNGSender contract, ETH amount needs to have been stored in the contract, it was transferred from or it can be paid when calling RNGSender.sendValue().

For more info,refer to

Randomizer
Obelisk
Obelisk
https://randomizer.ai/docs
Obelisk
Obelisk
https://layerzero.gitbook.io/docs/evm-guides/code-examples/estimating-message-fees
The RNG process between Ethereum and Arbitrum