# RISE Slots (/docs/cookbook/rise-slots)

import { Cards, Card } from 'fumadocs-ui/components/card';
import { Callout } from 'fumadocs-ui/components/callout';

## Introduction

In this tutorial, you'll build a fully onchain slot machine that showcases RISE's three most powerful features working together: **Fast VRF** for instant provably-fair randomness, **Session Keys** for gasless gameplay without popups, and **Shreds** for 3ms event streaming. This is a complete production-ready game with real token economics.

### What You'll Build

A complete casino-style slot machine with:

* Smart contracts: ERC20 game token + VRF-powered slot machine
* Symbol-based win detection with weighted probabilities
* Four payout tiers (15x to 500x)
* Session keys for completely gasless, popup-free gameplay
* Token faucet for broke players
* Real-time event watching with results caching
* Animated slot reels with instant VRF results
* Full game economy (10 RCT per spin, tiered payouts)

<Callout type="info">
  **Production Ready**: Unlike many tutorials that just demo features, this is a complete game ready for real users. All RISE features (VRF, Session Keys, Shreds) work together seamlessly in production.
</Callout>

### What You'll Learn

* Building VRF consumer contracts with symbol mapping
* Creating ERC20 tokens with game-specific features
* Session key permissions for gasless gameplay
* Ultra-fast event watching with Shreds WebSocket
* Results caching pattern for sub-millisecond UX
* P256 session key management in the browser
* Token economics and payout calculations
* Production patterns for onchain gaming

### Game Flow

1. **Player connects wallet** with RISE Wallet (passkey-based)
2. **Creates session key** (one popup, grants 7-day permissions)
3. **Claims 1000 RCT tokens** (one-time free claim)
4. **Player spins** (10 RCT per spin, completely gasless via session key)
5. **VRF returns 3 random numbers** in 3-5ms
6. **Contract maps numbers to symbols** and checks for matches
7. **Payouts distributed instantly** if player wins
8. **Events streamed via Shreds** for real-time UI updates
9. **Faucet refills broke players** with 1000 RCT

### Why This Matters

Traditional VRF solutions take seconds to minutes. RISE's VRF delivers results in **3-5 milliseconds**, and with Session Keys, players spin **without any wallet popups**. This tutorial shows you how to build the responsive, gasless UX that onchain gaming needs.

### Game Mechanics

**Symbol Probabilities** (for triple match):

* 🍒 Cherry (0-3): 6.4% chance → 15 RCT payout
* 🍋 Lemon (4-6): 2.7% chance → 30 RCT payout
* 💎 Diamond (7-8): 0.8% chance → 100 RCT payout
* 9️⃣ Lucky 9 (9): 0.1% chance → 500 RCT payout

**Economics**:

* Cost per spin: 10 RCT
* House starts with 10M RCT bankroll
* Expected return: \~31% (69% house edge)

### Prerequisites

Before starting, make sure you have:

* Node.js 18+ installed
* Basic knowledge of Solidity and React
* Foundry installed ([getfoundry.sh](https://getfoundry.sh))
* Some testnet ETH (get from [RISE Faucet](https://faucet.testnet.riselabs.xyz))

<Callout type="info">
  This tutorial uses RISE Wallet for gasless transactions. No private keys in code - everything is passkey-based and secure.
</Callout>

### Source Code

The complete source code for this project is available on GitHub: [awesamarth/rise-slots](https://github.com/awesamarth/rise-slots)

## Quick Links

<Cards>
  <Card title="Setup" href="/docs/cookbook/rise-slots/setup" description="Initialize project, install dependencies, and configure environment" />

  <Card title="Smart Contracts" href="/docs/cookbook/rise-slots/smart-contracts" description="Build RCT token and VRF-powered slot machine contracts" />

  <Card title="Session Keys" href="/docs/cookbook/rise-slots/session-keys" description="Implement gasless, popup-free gameplay with session keys" />

  <Card title="Event Watching" href="/docs/cookbook/rise-slots/event-watching" description="Set up Shreds for ultra-fast VRF result streaming" />

  <Card title="Frontend" href="/docs/cookbook/rise-slots/frontend" description="Build the animated slot machine UI" />
</Cards>
