Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random Number Generator #238

Merged
merged 50 commits into from
Oct 1, 2024
Merged

Random Number Generator #238

merged 50 commits into from
Oct 1, 2024

Conversation

0xNeshi
Copy link
Contributor

@0xNeshi 0xNeshi commented Jul 26, 2024

Issue(s): Close #128

Description

Built off of #183

Explain randomness in the context of blockchain, and Starknet specifically, and provide an example with CoinFlip contract.

Checklist

src/SUMMARY.md Show resolved Hide resolved
@0xNeshi 0xNeshi marked this pull request as draft July 30, 2024 12:32
@0xNeshi
Copy link
Contributor Author

0xNeshi commented Jul 30, 2024

Converting to draft: fixing the fee refund logic

@0xNeshi 0xNeshi marked this pull request as ready for review August 1, 2024 08:26
@0xNeshi 0xNeshi marked this pull request as draft August 1, 2024 10:05
@0xNeshi 0xNeshi marked this pull request as ready for review August 1, 2024 10:34
@0xNeshi
Copy link
Contributor Author

0xNeshi commented Aug 1, 2024

Converting to draft: fixing the fee refund logic

In the end simplified the contract logic to make the example focus more on the randomness generation part.

Copy link
Contributor

@julio4 julio4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Really good tests and nice to mock the randomness part as well.
Some small changes/comments and it'll be good!

src/applications/random_number_generator.md Outdated Show resolved Hide resolved
src/applications/random_number_generator.md Outdated Show resolved Hide resolved
src/applications/random_number_generator.md Outdated Show resolved Hide resolved
src/applications/random_number_generator.md Show resolved Hide resolved
src/applications/random_number_generator.md Outdated Show resolved Hide resolved
src/applications/random_number_generator.md Outdated Show resolved Hide resolved
listings/applications/coin_flip/src/contract.cairo Outdated Show resolved Hide resolved
listings/applications/coin_flip/src/contract.cairo Outdated Show resolved Hide resolved
Comment on lines 59 to 63
Below is an implementation of a `CoinFlip` contract that utilizes a [Pragma Verifiable Random Function (VRF)](https://docs.pragma.build/Resources/Cairo%201/randomness/randomness) to generate random numbers on-chain.

```rust
{{#include ../../listings/applications/coin_flip/src/contract.cairo}}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a quick explanation of the contract, with the different state Flipped and Landed, why we have both (contract call to oracle, then oracle call...), need to funds some eth to pay for fees.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know what you think 5c68e77

@0xNeshi 0xNeshi requested a review from julio4 August 9, 2024 11:33
Copy link
Contributor

@julio4 julio4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@julio4 julio4 merged commit 1e22588 into NethermindEth:main Oct 1, 2024
1 check passed
@julio4 julio4 mentioned this pull request Oct 3, 2024
2 tasks
@0xNeshi 0xNeshi deleted the randomness branch October 3, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Random number generation
3 participants