developer-grants icon indicating copy to clipboard operation
developer-grants copied to clipboard

PRNG - Pseudo Random Number Generator

Open justjoolz opened this issue 3 years ago • 3 comments

PRNG - Pseudo Random Number Generator

Grant category

Please select one:

  • Developer tools/services
  • Educational material

Description

A fully on-chain pseudo-random number generator written in Cadence and an off-chain Javascript equivalent that uses the exact same seeding mechanism (blockHash mixed with resourceID) and hence replicates the same stream of random data.

Problem statement

Using randomness is a big part of many NFT drops (randomized traits) and it's usually always done off-chain. This means it's harder to achieve transparency (most projects don't even attempt to). Also, it's prone to manipulation as has happened to several of Dapper's products.

  • Target audience

Developers + creators who value transparency.

  • Evidence for the need

15 posts on the forum mentioning randomness: https://forum.onflow.org/search?q=random and plenty in discord too, a very common question with no solutions

Off-chain randomness exploits:

https://blog.nbatopshot.com/posts/elite-pack-distribution-audit https://blog.nflallday.com/posts/update-rams-team-nft-drop https://nftevening.com/dapper-labs-hand-out-free-nfts-after-their-ufc-drop-is-a-total-disaster/

Proposed solution

A resource-based PRNG that lives in its own contract and can supply a stream of randomness from a provided initial seed.

Including helper functions for picking numbers in more useful and dev-friendly ways than unsafeRandom provides.

ie. pickFrom(["sandwich","noodles", [1,9] ) one in ten chance I get a sandwich, 9/10 noodles range(10,15) returns a random number between 10 and 15

Impact

This will allow developers to use randomness in their contracts in a far safer and more versatile way than is currently offered.

Milestones and funding

Milestone Deliverables Timeline Risks USD proposal
1 - MVP Implementation with detailed documentation in git repo including usage examples 1 month - 5k
X - Expansion Write a series of in-depth articles showcasing and detailing a variety of possible implementation patterns with their pros+cons 2 months - 10k
X - Maintenance + Adoption Resolving users' issues and providing hands-on support to developers who wish to safely and securely use randomization in their Dapps. At least 3 projects using PRNG on mainnet 3 months - 10k

Total funding proposed: 25k

Team

Name Role Bio Contact
Julian Developer Flow community representative + FlipFest winner [email protected]

justjoolz avatar Oct 13 '22 05:10 justjoolz

Hi @justjoolz - thanks again for your proposal! We're reviewing and will follow up shortly.

chrisackermann avatar Oct 14 '22 16:10 chrisackermann

Hi @justjoolz - thanks for your patience! Just wanted to let you know that we've accepted this submission and will be following up directly with next steps. Thanks!

chrisackermann avatar Oct 31 '22 13:10 chrisackermann

Hi @chrisackermann - thanks for the great news!

justjoolz avatar Nov 01 '22 02:11 justjoolz