Randomness Tutorial
Try It Out
What You'll Build
Mapping to the Randomness Flow
Conceptual Party
In Pancake Stacker
Prerequisites
Installation
The Smart Contract
Imports and State Variables
Events
Requesting Randomness: flipPancake()
Resolving Randomness: catchPancake()
Helper Function: getFlipData()
The Off-Chain Script
Setup
Step 1: Check Current Stats
Step 2: Request Randomness (Flip the Pancake)
Step 3: Get Flip Data
Step 4: Resolve Randomness via Crossbar
Step 5: Settle On-Chain (Catch the Pancake)
Step 6: Parse Events for Outcome
Complete Flow Diagram
Security Considerations
CEI Pattern (Checks-Effects-Interactions)
Settlement Delay
Try-Catch for Settlement
Running the Example
1. Clone and Install
2. Configure Your Wallet
3. Deploy the Contract
4. Run the Script
Expected Output
Summary
Last updated