For reference, this question is basically the same as this one, but for solidity.
Of course that in theory you can generate a random, unique, non-duplicate number using solidity. The problem is most solutions to this issue involve knowing beforehand all the possible values before running a randomizing code over them, and for thousands and thousands of different possibilities, storing that on-chain in the contract, that would probably end up being quite expensive gas-wise.
If I want to generate a unique, non-duplicate, random number in a solidity contract, can I do so without actually storing ALL of the possible outcomes on the contract itself? Is it possible to retrieve that data from offchain? Or maybe store it on-chain and retrieve from onchain, but do it in a cheap way?