I understood that solidity can only generate pseudo-random numbers. Although, is there any way of generating a, let's say 10 character, random string?
1 Answer
If you only want pseudo-random, and you aren't concerned about malicious actors gaming/breaking your system... then most people seem to take one of these approaches:
1) Using a hash of various block information
Edit: I'M NOT ENDORSING THIS. YOU WILL BE GAMED.
For example:
function genRandom() private view returns (uint) {
uint rand = uint(keccak256(block.blockhash(block.number-1)));
return uint(rand % (10 ** 20));
}
source: https://gist.github.com/austintgriffith/de01418675238d5292fcc7fe0de5586c#file-etherbots
Ethernaut level 3 shows just how easy this is to exploit...
2) Using a trusted oracle to source a random number for your contract.
Each approach has limitations and constraints already documented extensively.
Context: How can I securely generate a random number in my smart contract?