Questions tagged [random]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
2 answers

Generating random numbers in ink!

I've been trying to use most common let mut rng = rand::thread_rng(); let winner_pos = rng.gen_range(0..10); way to get a random number and use it in one of the contract's messages. But it throws a ...
7 votes
2 answers

Secure random number generation?

I've been watching Substrate_ tutorials for a while now, with the goal of learning a little more about their technology. My question is: Would random number generation using Randomness be feasible in ...
0 votes
0 answers

How to generate random number of a specific length in Substrate pallet

I want to generate random number of a specific length. I can't use insecure-randomness-collective-flip because it's not recommended for production. I also can't use rand package because it doesn't ...
2 votes
1 answer

How to select n random keys from a `StorageMap`?

Assume I have the following storage map: ZAccounts: StorageMap(AccountId -> AccountInfoOf<T>) Is there a simple way to draw n AccountId's randomly. I assume that I already have a secure ...
3 votes
1 answer

What does `no particular order` mean for storage iterations?

I am always curious what the documentation for the storage means when I see the following. Enumerate all elements in the map in no particular order.
1 vote
1 answer

Is the random number generation safe for pallet_lottery?

I read this post of Shawn and found out, that random numbers for lotteries are not reliable, even with VRF on GRANDPA since the validators could earn ...
1 vote
1 answer

Test panic with Randomness::random() 'attempt to subtract with overflow'

Sorry for the title but I don't know how to explain it better. I have this simple custom pallet and I try to test the create_random_number dispatchable function with a simple assert_ok! but I get this ...
0 votes
1 answer

How to use "A secure, local entropy source for random number generation" in offchain worker?

The official website tells us there is " A secure, local entropy source for random number generation" . I think it means that I can make use of this feature to generate random number or even ...
4 votes
1 answer

On-chain pseudo-random numbers - agreed by all

I'm looking for a source of random numbers - doesn't need to be cryptographically secure, just hard to predict in advance but agreed by and visible to all participants. I'm thinking about using the ...