Tezos Randomizer is a contract that you can call from your own contracts to get a random number between X and Y - on-chain ⛓️.
It comes with a service that can be used to generate new entropy every X minutes (currently every 30 minutes for mainnet).
It also has entrypoints
and views
where you can "bring your own entropy".
If you use this software, donate 👉 tz1UZZnrre9H7KzAufFVm7ubuJh5cCfjGwam
NB!!! The Tezos Randomizer is deterministic. This means that a tech savvy user can predict the outcome of the randomizer for a transaction within a specific block by simulating transactions and front-running the entropy-pusher services. If you have a high value use-case, please make sure to read this and provide your own entropy to the randomizer.
- Mainnet
- Ghostnet
- Ithacanet
- Hangzhounet
- Mainnet
- Hangzhounet
- Granadanet
# v3.0.0
Randomizer = sp.io.import_script_from_url("https://ipfs.infura.io/ipfs/QmPNkabMCpDmFE6GynfS9UAoQDLE6PyCLpRJQmceEp2oTv")
# v2.0.0
Randomizer = sp.io.import_script_from_url("https://ipfs.infura.io/ipfs/QmWMFUneMRphK1uGKZaYjRXo8eJxRxB9rLU453DHrrBE1w")
# v1.0.0
Randomizer = sp.io.import_script_from_url("https://ipfs.infura.io/ipfs/QmeQ8QUmbQ1oV9FQb65UxgbM5323yuKNFgk3WgTzgzeY3E")
./scipts/init-env.sh
source bin/activate
spy kind all tests.py output --html
spy compile compile.py compiled
spy originate-contract --code compiled/randomizer/step_000_cont_0_contract.tz --storage compiled/randomizer/step_000_cont_0_storage.json --rpc https://hangzhounet.smartpy.io
getRandomBetween
parameters:
_from: TNat
_to: TNat
Get a random number between _from and _to using storage entropy.
getRandomBetweenEntropy
parameters:
_from: TNat
_to: TNat
entropy: TNat
Get a random number between _from and _to using passed entropy (Nat).
getRandomBetweenEntropyBytes
parameters:
_from: TNat
_to: TNat
entropy: TBytes
includeRandomizerEntropy: TBool
Get a random number between _from and _to using passed entropy (Bytes).
Concatenate passed entropy with randomizer entropy by passing includeRandomizerEntropy=True.
getRBC
parameters:
_from: TNat
_to: TNat
callback_address: TAddress
Get a random number between _from and _to using storage entropy.
Does a callback with the result to `callback_address`.
getRBCE
parameters:
_from: TNat
_to: TNat
entropy: TNat
callback_address: TAddress
Get a random number between _from and _to using passed entropy.
Does a callback with the result to `callback_address`.
getRBCEB
parameters:
_from: TNat
_to: TNat
entropy: TBytes
includeRandomizerEntropy: TBool
callback_address: TAddress
Get a random number between _from and _to using passed entropy.
Concatenate passed entropy with randomizer entropy by passing includeRandomizerEntropy=True.
Does a callback with the result to `callback_address`.
- Look into rejection sampling
- Entrypoint to get multiple values (unique / non-unique optionally)
enjoy.