I need to generate a random number in range 1-5000 which are non duplicate.
I had found solution to generate random number in particular range using chainlink and without chainlink also but i need to generate non repeative number in that particular range.
solidity – Generating a Non-Repetitive Random Number in a Specific Range
chainlinkcontract-developmentnftrandomnesssolidity
Best Answer
The key to solving this (how we do it at least) is using array indexes. It's still tricky as in Solidity we are very limited in what we can do with arrays, there is no way to slice, flip etc.
Here is a working approach.
(Note: this assumes you fulfil randomness via chainlink or otherwise in the getRandomNum function. Modify accordingly.)
Put this inside constructor:
Put the below inside your mint function or wherever you need it:
Hope this helps!