/crypto
Blockchain, crypto, and Web3
submit
ad
Advertise in /crypto
Reach our crypto-focused community

Best solution to get a random number in a smart contract?

How to get a random number in Solidity.

4d|
Anonymous
|reply||
7 comments
bro thought this was chatgpt
4d|
Anonymous
||
There are oracles that can provide random numbers. Chainlink I believe can and theyre the largest oracle.
4d|
Anonymous
||
very naive of you to trust them
1d|
Anonymous
||
Or you could get timestamp of recent block and use it as seed in some prg if you don't need much entropy
3d|
Anonymous
||
> Or you could get timestamp of recent block and use it as seed in some prg if you don't need much entropy

With other words, if you're alright with someone being able to predict the random number
3d|
Anonymous
||
Yup perfectly alright for games. And how you gotta predict next block timestamp? You might get just enough entropy for uniform 0-1
1d|
Anonymous
||
use the least significant bits of the number of transactions of some coin
1d|
Anonymous
||
Add a comment
0/2000