⚔️ Quick Draw Arena - Project Story

Inspiration

I was playing a competitive PvP game late at night when my opponent accused me of cheating. I hadn't cheated, but I realized something profound: I had absolutely no way to prove it.

This moment crystallized gaming's fundamental problem - trust. Every online game requires players to trust that the game servers aren't rigged, other players aren't using undetectable hacks, and results are actually fair. There's no transparency, no verification, just blind faith in centralized systems.

As a Starknet developer with one year of ecosystem experience, I knew the blockchain infrastructure was finally mature enough to solve this problem. Dojo 1.0 had just launched with provable game engines. Cartridge Controller solved the Web3 UX nightmare with session keys. Starknet's 2-second finality made real-time competitive gaming viable.

I saw an opportunity to build something revolutionary: a game where cheating isn't just discouraged - it's mathematically impossible. Quick Draw Arena became that vision realized.


What it does

Quick Draw Arena is a 1v1 commit-reveal dueling game where players compete in best-of-3 matches using rock-paper-scissors-style combat with real cryptocurrency stakes.

Core Gameplay

Players face off in fast-paced duels:

  • Attack beats Defend (charge past their shield)
  • Defend beats Special (block their fancy move)
  • Special beats Attack (outmaneuver their charge)
  • Best of 3 rounds - first to 2 wins takes the match
  • Players stake $DUEL tokens on each match
  • Winner automatically receives the entire pot

The Revolutionary Part: Cryptographic Fairness

Unlike traditional games where you trust the server, Quick Draw Arena uses a commit-reveal cryptographic pattern that makes cheating mathematically impossible:

Commit Phase: Both players secretly choose their action and submit a cryptographic hash using Poseidon. Your opponent cannot see what you chose - they only see gibberish.

Reveal Phase: Both players reveal their actual moves plus a secret "salt." The smart contract verifies that the revealed move matches the earlier commitment hash.

Resolution: The contract automatically determines the winner based on rock-paper-scissors logic and distributes tokens to the victor.

The Result: You cannot change your move after seeing your opponent's choice. You cannot peek at their move before committing yours. The game logic is transparent and auditable on-chain. Every action is cryptographically verifiable.

Token Economy with OpenZeppelin

$DUEL Token (ERC20): Built using OpenZeppelin's audited contracts for maximum security. The token serves as the game's wagering currency, with automatic escrow during matches and instant winner payouts.

Achievement NFTs (ERC721): Players earn collectible badges for accomplishments:

  • 🥉 Bronze Winner (first win)
  • 🥈 Silver Winner (5 wins)
  • 🥇 Gold Winner (10 wins)
  • 🔥 Win Streak badges (3 or 5 consecutive wins)
  • 💎 High Roller (win with 10+ DUEL wager)

These NFTs are minted automatically by the game contract when milestones are reached, proving on-chain accomplishments that are tradeable on any marketplace.


How we built it

Tech Stack

Smart Contracts (Fully On-Chain):

  • Dojo Engine 1.7.0: ECS architecture for clean game state management
  • Cairo: Provable computation language ensuring trustless logic
  • OpenZeppelin v0.18.0: Audited ERC20/ERC721 token standards
  • Poseidon Hashing: Cairo-native cryptographic commitments
  • Starknet Sepolia: Public testnet deployment

Frontend:

  • React + TypeScript: Modern web framework
  • Cartridge Controller: Session keys for gasless gameplay
  • Starknet React: Blockchain connectivity hooks
  • Torii Indexer: Real-time game state subscriptions
  • Tailwind CSS: Responsive, beautiful UI

Development Tools:

  • Sensei MCP: AI assistant providing expert Dojo guidance
  • Katana: Local Starknet sequencer for testing
  • Sozo: Dojo deployment and migration tool

Challenges we ran into

Commit-Reveal Cryptographic Security

The Problem: How do you ensure players cannot cheat by seeing their opponent's action before committing their own?

The Solution: We researched cryptographic commitment schemes and chose Poseidon hashing because it's Cairo-native and highly efficient. We implemented a two-phase system where players first submit a hash of their action plus a random salt, then later reveal the action and salt for verification. The contract checks that the revealed data matches the original commitment hash. We used sufficiently random salt generation and added validation to prevent players from revealing without committing first.

The Learning: Cryptographic patterns require careful thought about edge cases and potential attack vectors. Every detail matters for security.

OpenZeppelin and Dojo Integration

The Problem: Combining two different Cairo frameworks - Dojo's ECS architecture and OpenZeppelin's component-based contracts - in one cohesive project.

The Solution: We created separate token contracts for DUEL and Achievement NFTs using pure OpenZeppelin patterns. The game systems interact with these contracts via Cairo's dispatcher pattern for cross-contract calls. We studied both frameworks' architectures thoroughly and tested the integration extensively on Katana before deploying to Sepolia.

The Learning: Cairo's component system is powerful but requires understanding dispatcher patterns and proper trait implementations for cross-contract communication.

Cartridge Controller Session Keys

The Problem: Session keys were relatively new technology with limited examples and initially complex-looking documentation.

The Solution: We started with minimal configuration and added complexity gradually. We defined explicit session policies for each game method (create_match, join_match, commit_action, reveal_action). Most critically, we configured HTTPS correctly in Vite because Cartridge Controller requires secure connections. We tested the authentication flow thoroughly before building game features.

The Learning: Session keys are the UX breakthrough that makes blockchain gaming viable. They transform the experience from "sign 50 transactions" to "approve once, play freely" - exactly what mainstream gamers need.

State Management Across Rounds

The Problem: Managing match state through multiple rounds with both players' commitments, reveals, and score tracking was complex.

The Solution: We leveraged ECS architecture effectively by separating Match and RoundCommitment into distinct models. We implemented a clear state machine with transitions from Waiting to InProgress to Complete. We added a round counter to track progress and implemented automatic initialization of the next round after each resolution. When a player wins 2 rounds, the match ends and rewards distribute automatically.

The Learning: ECS architecture shines when you properly separate concerns. Each model should represent a distinct concept, and systems should have single, clear responsibilities.

Real-Time Updates

The Problem: Players need to see when their opponent commits or reveals actions without manually refreshing the page.

The Solution: We integrated Torii indexer's GraphQL subscriptions for blockchain event monitoring. When events occur, React state updates trigger UI re-renders automatically. We added loading states for better user feedback and implemented a polling fallback every 5 seconds for reliability in case subscriptions fail.

The Learning: Torii's real-time capabilities are perfect for gaming. Players get instant feedback without centralized servers or complex WebSocket infrastructure.

Testing on Public Testnet

The Problem: Debugging on Sepolia is slower than local testing. Transactions take time to confirm, mistakes consume testnet tokens, and iteration cycles are longer.

The Solution: We tested extensively on Katana first where feedback is instant and iterations are free. We used Starkscan explorer to debug any failed Sepolia transactions. We implemented detailed console logging in contracts for troubleshooting. We only deployed to Sepolia after all local tests passed successfully.

The Learning: Always test locally first. Public testnets should be for final validation, not active development.


Accomplishments that we're proud of

First Commit-Reveal PvP Game on Starknet

After researching the entire Starknet gaming ecosystem, we found zero commit-reveal dueling games. There's Shoshin (async/pre-programmed fighting), Eternum and Loot Survivor (strategy games), but nothing with real-time competitive dueling using cryptographic commitments. We created an entirely new genre on Starknet.

Mathematically Provable Fairness

This isn't just "blockchain gaming" - it's provably fair gaming. The commit-reveal pattern makes cheating mathematically impossible. Players cannot see their opponent's move before committing. Players cannot change their move after committing. The game logic is transparent and auditable on-chain. Every action is cryptographically verifiable. The code is the referee - no trust required.

Complete Token Economy with OpenZeppelin

We didn't just add tokens as an afterthought - we built a functioning economy. The ERC20 DUEL token handles all wagering using audited OpenZeppelin contracts. The game provides automatic escrow during matches and instant winner payouts. ERC721 Achievement NFTs are earned through gameplay milestones and represent real on-chain accomplishments. Smart access control ensures only the game contract can mint NFTs. Every token has real utility beyond speculation.

Web2-Level User Experience

Most blockchain games feel clunky with constant wallet popups. Quick Draw Arena feels smooth. One-click login via Cartridge Controller requires no seed phrases or confusing addresses. Session keys mean players approve once then play freely without interruptions. Real-time updates via Torii feel instant. Starknet's 2-second finality enables true competitive timing. Players who don't know crypto can still play comfortably.


What we learned

Technical Insights

Commit-reveal patterns require meticulous design. Hash functions must be collision-resistant like Poseidon. Salt must be truly random and unpredictable. State management across commit and reveal phases needs careful planning. Edge cases matter - what happens if one player doesn't reveal?

Dojo ECS is powerful for game state management. The Entity Component System makes complex state elegant. Models define data structure clearly. Systems define logic separately. World handles storage automatically. Clean separation of concerns scales well as games grow more complex.

Session keys are the UX breakthrough blockchain gaming needed. Before session keys, players signed 50+ transactions per game - terrible UX. After session keys, players approve once and play freely - amazing UX. This single innovation makes blockchain gaming mainstream-ready.

Starknet is fast enough for competitive gaming. Two-second finality means players don't wait between moves. Matches feel smooth and responsive. Real competitive gaming is finally viable on blockchain. Coming from Ethereum's 12-second blocks, this was revelatory.

Design Principles

Simplicity wins in game design. We almost built complex combos and special moves. Rock-paper-scissors is instantly understandable - perfect for demonstrating the core innovation of provable fairness without drowning players in complexity.

Lead with value proposition, not technical details. Players don't care about "ECS architecture" or "provable computation" - they care that cheating is impossible. Technical details matter for judges and developers. For players, focus on tangible benefits.

Web2 UX is non-negotiable for mainstream adoption. A simple game with smooth UX beats a complex game with clunky Web3 interactions every single time. Session keys, one-click login, and no transaction popups aren't nice-to-haves - they're requirements.

Token utility must be genuine. Don't add tokens for the sake of having tokens. DUEL creates economic stakes that give players real reason to win. Achievement NFTs prove accomplishments and provide bragging rights. Both have clear purpose in the game loop.


What's next for QuickDraw

Immediate Priorities

Polish and user feedback. Fix bugs discovered during demos, improve mobile responsiveness, add loading animations and better error messages, gather feedback from players and iterate quickly.

Enhanced UI. Add sound effects for actions like attack swoosh and defend clang, improve visual feedback for round results, add celebration animations for winners, display comprehensive match history in player profiles.

Matchmaking system. Implement automatic matchmaking instead of manual joining, match players with similar wager amounts, show queue position and estimated wait time, add quick-match option for instant duels.

Short-Term Development

Tournament infrastructure. Create tournament smart contracts with prize pool escrow, build bracket generation and management systems, enable community-hosted tournaments with customizable rules, add tournament registration with entry fees, implement automated prize distribution.

Leaderboards and rankings. Build global leaderboard based on wins and win rates, implement seasonal rankings with special rewards, create division system from Bronze through Diamond, add rank-based matchmaking for balanced competition.

Social features. Enable friend challenges to specific players, add emotes and quick chat options, implement spectator mode for watching live matches, allow sharing match replays on social media.

Expanded achievements. Add Perfect Game badge for 2-0 wins without losing rounds, Comeback King for wins after losing first round, Speed Demon for sub-30-second victories, Marathon Runner for 100 total matches played, token-gated achievements that unlock special features.

Medium-Term Goals

Multiple game modes. Ranked mode with competitive ladder and skill-based matchmaking, casual mode with no wagers for practice, AI practice mode to learn mechanics, tournament mode with special competitive rulesets, high-stakes mode with minimum 100 DUEL wagers for professionals.

Mobile application. Build native iOS and Android apps using React Native, create touch-optimized controls, implement push notifications for match updates, add offline queue where players get notified when matched.

Enhanced gameplay depth. Introduce fourth action type for more strategic depth, add character selection with different stats and abilities, implement power-ups and special abilities unlocked via NFTs, create daily challenges with bonus rewards.

Creator economy. Enable custom tournaments with player-defined rules, allow community-created challenges, give tournament organizers percentage of entry fees, integrate sponsored tournaments with brand partnerships.

Long-Term Vision

Stwo prover integration. Implement client-side proving for private matches, enable hidden strategies so opponents can't analyze patterns, create verifiable replays without exposing real-time data, add advanced anti-cheat through zero-knowledge proofs.

Cross-chain expansion. Deploy to Starknet Layer-3 chains dedicated to gaming, bridge DUEL tokens across multiple chains, maintain unified leaderboard across all deployments, host cross-chain tournaments.

Team battles. Build 2v2 and 3v3 team modes, create guild system with shared rankings, enable team tournaments with split prize pools, implement guild wars with territory control mechanics.

Esports integration. Partner with established gaming organizations, launch sponsored professional leagues, integrate with streaming platforms like Twitch and YouTube, host live tournaments with professional commentary, build prize pools reaching thousands of dollars.

Advanced token economics. Implement DUEL burning mechanism for deflationary pressure, build NFT marketplace for achievement trading, create rare legendary achievements earned by less than 1% of players, add staking mechanisms with bonus rewards, enable governance voting for game balance changes.

Built With

Share this project:

Updates