How does Sophia get random numbers

How do you get a random number in Sophia?
Let’s say it goes from 0 to 100

Like the Java language
JAVA : random.nextInt(100)

@hanssv.chain Teacher, do you know?

This is a blockchain - in short, you can’t get a random number…

You can get a pseudo-random number by deriving from the blockhash or similar. Or you could ask an Oracle for a random number.


Why are there no random numbers in the blockchain?

Can you add it in AE?

Because the call transaction is evaluated by every node that receives it, and must return the same result every time in order to be considered valid. Sophia contracts must be fully deterministic.

This is why you could get away with a pseudo-random number, but not a truly random one.


I’ve learned thank you

@Baixin.chain as already mentioned on discord I suggest you to talk to @VitalJeevanjot regarding the random numbers via oracles.

ideally we would be able to provide sth. similar to the solution of ChainLink here: Verifiable Randomness for Blockchain Smart Contracts


@Baixin.chain @marco.chain
yes, there are many ways, One of them is what chainlink offers. For “Say Network” I am planning a similar module in future.

1 Like

@marco.chain @VitalJeevanjot It would be nice if Oracle2.0 could provide it, and share the implementation so that random numbers are enough to be de-centered

“Oracle 2.0” (Say Network) will provide it in future.

1 Like

That’s great. Love you :smiling_face_with_three_hearts: