0

I am writing a contract in smartpy where I need to generate a random number between two numbers. I see mostly people are depending on Harbinger oracle.

  1. I want to know if there is any other way on smartpy to generate a random numbers. Is there any code for that ?
  2. What is the best way to generate a random number in smartpy?

1 Answer 1

0

At the moment there is no way to generate a random number in Michelson so there is no way to do it directly in SmartPy.

You can rely on an Oracle or techniques such as Verifiable Random Function (VRF).

A ressource to read on that subject: https://opentezos.com/smart-contracts/avoiding-flaws/#7-using-unreliable-sources-of-randomness.

A related question with interesting answer: Random number on-chain

2
  • Has anyone already implemented a VRF on smartpy ? Can I take reference from their code? Which oracle would you suggest for now?
    – Kin
    Commented Nov 29, 2022 at 17:04
  • You may reach the Plenty team. Maybe they've done something with VRF. Also you can reach the Kolibri team for an Oracle. Please share them this page so they can add answers.
    – Jordan_tez
    Commented Dec 3, 2022 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.