onflow / random-coin-toss

An example repo demonstrating safe use of onchain randomness
The Unlicense
5 stars 4 forks source link

Complete end-to-end walkthrough #1

Open sisyphusSmiling opened 1 year ago

sisyphusSmiling commented 1 year ago

Description

Complete an end-to-end walkthrough demonstrating onchain randomness and PRG implementation building on the RandomBeaconHistory contract & heartbeat.

Dependency

The current CoinToss contract depends on the existence of a blockwise source of randomness in the RandomBeaconHistory contract. In order to test the application level contract, we need a way to commit that source of randomness at every block; however, the emulator increments the block height with every transaction submission.

This means that end-to-end testing of the CoinToss contract, demonstrating a commit-reveal mechanic along with PRG implementation, is dependent on the RandomBeaconHistory heartbeat submission being embedded in at least a preview version of the emulator.

tarakby commented 1 year ago

Thanks for creating this new repo. I was wondering where does the PRG contract itself live (in case it already exists)? Thanks

sisyphusSmiling commented 1 year ago

@tarakby this is the initial implementation with just a single nextUInt64() method at the moment. I'm in the process of building out some statistical tests (#3). Any feedback on the implementation is welcome ofc!