Randomness for NFT packs on Flow

Hi all,

I’m currently working on an NFT Marketplace on the flow blockchain. I am hoping to find a way to implement a pack that returns a random NFT (similar to NBA Topshot). I have seen the Cadence documentation for unsafeRandom() but I am not sure how to implement it (also the playground doesn’t support it).

I would appreciate any input.

Thanks!

It isn’t safe because a user could revert the transaction and retry as many times as they want until they get the random number that they want.

Check out the docs for how to use it: Built-in Functions - Flow Documentation