Random number generator

Hi there, is there a means to get a random number in a teal smart contract? Is there something like a VRF primitive we can use? Chainlink VRF does this, and I’m wondering if it’s something we would have something similar at our disposal on the Algorand blockchain. Any ideas or first steps for research would be very appreciated.

Currently TEAL does not provide an opcode for random number generation nor verification of a VRF.

I think that currently the best two options are:

  1. If the contract is for something like a bet over a coin toss, the parties involved may commit to random values (e.g., using SHA256), and then reveal the committed value. The randomness consists in the XOR of all those committed values. If a party does not reveal its value in time, some slashing must be performed.
  2. Have an external oracle. There are multiple ways to implement an oracle. One very simple way nowadays may just to have an application that stores the oracle value in its global state

If this is not confidential, what kind of dapps are you building?

Notes:

  1. The “seed” used for the sortition (stored in each block) is not uniformly random.
  2. TEAL is for layer-1 smart contracts. Layer-2 smart contracts will allow for much more complex smart contracts.