RNGSender
RNGSender's main job is to send random numbers generated in Arbitrum to a chain where Obelisk exists.
Last updated
RNGSender's main job is to send random numbers generated in Arbitrum to a chain where Obelisk exists.
Last updated
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 numbers are generated by Randomizer, 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.
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
.
Actually RNGSender.request()
is called automatically when a LayerZero message arrives from Obelisk contract on another chain. Only when that fails, owner
can call it manually with proper arguments.
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().
Since the value is paid from RNGSender contract, ETH amount needs to have been stored in the contract, it was transferred from Obelisk or it can be paid when calling RNGSender.request()
.
For more info, refer to https://randomizer.ai/docs.
After a random number is generated, it needs to be transferred back to Obelisk contract automatically or by calling RNGSender.sendValue()
.
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.
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()
.
Since the value is paid from RNGSender contract, ETH amount needs to have been stored in the contract, it was transferred from Obelisk or it can be paid when calling RNGSender.sendValue()
.
For more info,refer to https://layerzero.gitbook.io/docs/evm-guides/code-examples/estimating-message-fees