Let's say a player encounters an enemy on a grid-based game, how can I generate a random number on chain to generate the enemy basic characteristics ( HP, strength, agility... ) at the time of the attack? Or the amount of a treasure contained in a chest?

According to this answer and this implementation by Asbjornenge one way is to originate a contract and use its address as a seed to get randomness, and provides entropy using Harbinger Oracle. How is this address generated and how predicatble is it?

Is there a faster/safer/better/less predictable way to get randomness on chain if the game manages a great amount of ꜩ, or should I go with Asbjornenge's implementation?


1 Answer 1


You can use Acurast data providers to generate secure random bytes from inside a TEE(Trusted Execution Environment)

How does it work?

You schedule a job in this contract where you provide the script for generating the random bytes and a few other job configurations, like the destination contract(Your game).

Currently, the jobs can only be registered by the administrator. Let me know if you are interested, I can put you in contact with the developers.

The job will look like this: enter image description here

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.