Application 3: Mempool Duel

Table of contents
- Current Deployment Status โ
- Game Concept
- Game Story
- Gameplay Mechanics
- How Blocklock Solves the Fairness Problem
- ๐ Features
- ๐ ๏ธ Technology Stack
- ๐ Prerequisites
- ๐ Quick Start
- ๐ฏ How to Play
- ๐๏ธ Project Structure
- ๐ง Configuration
- ๐งช Testing
- ๐ Deployment
- ๐ค Contributing
- ๐ License
- ๐ Acknowledgments
- ๐ Support
- ๐ฎ Roadmap

First and foremost, the demo and the github repo. I would truly appreciate any feedback, so donโt hold back ; )
A little disclaimer, Iโve never really built a game and this is my first attempt at building one. I was not able to make the frontend work in time, but the contract is deployed and working.
Current Deployment Status โ
Base Sepolia Testnet (Chain ID: 84532)
Contract Address:
0xF0Fb1a485571Db8475A1271C6f7f47b695e51971
Blocklock Sender:
0x82Fed730CbdeC5A2D8724F2e3b316a70A565e27e
Deployment Block:
30023696
Transaction Hash:
0x36f54706e398d6da62d88c007066a125a04276c971a750d039575fe9478d6d02
Verification: โ Verified on Basescan
Gas Used:
2,398,063
gasCost:
0.000002398202087654 ETH
Contract Parameters
Min Wager:
0.001 ETH
(1,000,000,000,000,000 wei)Max Wager:
1 ETH
(1,000,000,000,000,000,000 wei)Timeout Blocks:
100
blocks
Game Concept
Mempool Duel is a quick, high-stakes, two-player web game based on the classic "Rock, Paper, Scissors" logic. It's designed for fast rounds of play where fairness is cryptographically guaranteed. The game is framed as a conflict between two rival data couriers in a cyberpunk universe, settling their disputes through a quick, decisive digital duel.
Game Story
In the neon-drenched metropolis of Neo-Kyoto, information is the most valuable currency. Rival data couriers, known as "Runners," constantly vie for supremacy on the digital frontier. When two Runners cross paths with conflicting contracts, disputes are settled not with weapons, but with code. Mempool Duel is the digital arena where these conflicts are resolvedโa lightning-fast game of strategy where a single move can determine the outcome. Victory requires anticipating your opponent's logic, but the system's integrity is absolute, ensuring no Runner can cheat the code.
Gameplay Mechanics
The Wager: Two players connect their wallets to the game's smart contract. To initiate a duel, they each place a small, equal wager (e.g., 1 MATIC, 5 USDC) into the contract, which holds the total pot in escrow.
The Choice: Both players are simultaneously presented with three choices for their move:
ICE (Rock): A brute-force defensive program.
Spike (Paper): A sharp, invasive script that bypasses defenses.
Glitch (Scissors): A disruptive code snippet that corrupts invasive scripts. (The classic rules apply: ICE breaks Glitch, Glitch corrupts Spike, Spike bypasses ICE).
The Blocklock Commit: Once a player selects their move, the game's front-end uses
blocklock-js
to encrypt their choice. The decryption condition is set to atargetBlock
just a few blocks into the future (e.g., current block + 3) to ensure a rapid game resolution.The Duel: Each player submits their single, encrypted transaction to the game's smart contract. The blockchain records that both players have submitted their moves, but the moves themselves remain completely secret and unreadable.
The Reveal & Resolution: When the
targetBlock
is reached, the dcipher network automatically delivers the decryption keys for both moves to the smart contract. The contract instantly executes aresolveDuel
function which:Decrypts both moves simultaneously.
Determines the winner based on the game's logic.
Automatically transfers the entire pot to the winner's wallet.
In the event of a draw (e.g., both choose ICE), the wagers are automatically returned to each player.
How Blocklock Solves the Fairness Problem
Blocklock's primary role in Mempool Duel is to solve the fundamental challenge of fairness in on-chain games of simultaneous choice.
The Problem with Transparency: On a public blockchain, all pending transactions are visible in a "waiting room" called the mempool. Without encryption, if Player 1 submits their move "ICE," Player 2 could see this pending transaction and simply submit the winning counter-move, "Spike," with a higher fee to ensure their transaction is processed first. This is a form of front-running that makes a fair game impossible.
The Old Solution (Commit-Reveal): The traditional way to solve this was a two-step "commit-reveal" scheme. Players would first submit a hash of their move (the "commit"), and then, in a second transaction, submit the actual move (the "reveal"). While this works, it has significant drawbacks:
Poor User Experience: It requires each player to make two separate transactions, which is inconvenient and doubles the gas fees.
Reveal Dependency: The game can stall or fail if a player decides not to submit their reveal transaction, especially if they anticipate losing.
The Blocklock Advantage: Blocklock provides an elegant, single-step solution. By encrypting the move, it achieves both "commit" and "reveal" in one action.
Hiding: The move is completely hidden from the opponent while in the mempool, preventing any front-running attacks.
Binding: Once the transaction is submitted, the move cannot be changed.
Automated Reveal: The reveal is handled automatically and simultaneously for both players by the smart contract when the time condition is met. This removes the dependency on players to submit a second transaction.
This makes Mempool Duel a provably fair mini-game where victory is determined by strategy and psychology, not by who has the fastest connection or the most technical skill at monitoring the blockchain.
๐ Features
๐ฎ Core Gameplay
Three Strategic Moves: ICE (Rock), Spike (Paper), Glitch (Scissors)
Cryptographic Fairness: Time-locked encryption prevents cheating
Instant Resolution: Automatic decryption and payout when conditions are met
Wager System: Place bets in MATIC, USDC, or other supported tokens
๐ Security & Transparency
Blocklock Encryption: Uses dcipher network for time-locked encryption
Smart Contract Escrow: Automated wager holding and payout
On-Chain Verification: All game results are publicly verifiable
No Front-Running: Encrypted moves prevent manipulation
๐จ User Experience
Pixel-Art Aesthetic: Retro gaming style with modern blockchain functionality
Responsive Design: Works seamlessly on desktop and mobile devices
Real-Time Updates: Live game status and blockchain confirmation
Wallet Integration: Seamless MetaMask and other wallet connections
๐ ๏ธ Technology Stack
Frontend
Next.js 13 - React framework with App Router
TypeScript - Type-safe development
Tailwind CSS - Utility-first CSS framework
Wagmi - React hooks for Ethereum
Ethers.js - Ethereum library
Blockchain
Solidity - Smart contract development
Hardhat - Development environment
Blocklock-js - Time-locked encryption
dcipher Network - Decentralized encryption infrastructure
Networks Supported
Base Sepolia (Testnet) - Primary development network
Polygon Mumbai (Testnet) - Alternative testnet
Ethereum Sepolia (Testnet) - Ethereum testnet
๐ Prerequisites
Before you begin, ensure you have the following:
Node.js (v16 or later)
npm (v7 or later) or yarn
MetaMask or compatible Web3 wallet
Test tokens for your chosen network
Basic knowledge of blockchain and Web3 concepts
๐ Quick Start
1. Clone the Repository
git clone https://github.com/yourusername/mempool-duel.git
cd mempool-duel
2. Install Dependencies
npm install
# or
yarn install
3. Environment Setup
Create a .env.local
file in the root directory:
# Network RPC URLs
NEXT_PUBLIC_BASE_SEPOLIA_RPC_URL=https://sepolia.base.org
NEXT_PUBLIC_POLYGON_MUMBAI_RPC_URL=https://rpc-mumbai.maticvigil.com
# Contract Addresses (Base Sepolia - Deployed)
NEXT_PUBLIC_MEMPOOL_DUEL_CONTRACT=0xF0Fb1a485571Db8475A1271C6f7f47b695e51971
NEXT_PUBLIC_BLOCKLOCK_SENDER=0x82Fed730CbdeC5A2D8724F2e3b316a70A565e27e
4. Start Development Server
npm run dev
# or
yarn dev
Open http://localhost:3000 in your browser to see the application.
5. Test the Deployed Contract ๐งช
The contract is already deployed on Base Sepolia testnet! To test it:
Switch to Base Sepolia in your wallet
Get test ETH from the faucet links above
Connect your wallet to the game
Create a duel with 0.001 ETH wager
Test the game flow with another player
๐ฏ How to Play
1. Connect Your Wallet
Click "Connect Wallet" and authorize your Web3 wallet
Ensure you're on a supported network (Base Sepolia recommended)
Have test tokens ready for wagers
2. Join or Create a Duel
Quick Duel: Get matched automatically with another player
Create Duel: Set your own wager amount and wait for challengers
Join Duel: Accept an existing challenge from the Duel Board
3. Make Your Move
Choose from three strategic options:
ICE ๐ง: Defensive program (beats Glitch)
Spike โก: Invasive script (beats ICE)
Glitch ๐: Corruptive code (beats Spike)
Your choice is encrypted and committed to the blockchain
4. Wait for Resolution
Both players' moves remain encrypted until the target block
The dcipher network automatically delivers decryption keys
Smart contract resolves the duel and distributes winnings
5. Claim Your Victory
Winners automatically receive the entire pot
Draws result in wager returns to both players
All results are verifiable on-chain
๐๏ธ Project Structure
mempool-duel/
โโโ app/ # Next.js App Router
โ โโโ globals.css # Global styles and pixel-art theme
โ โโโ layout.tsx # Root layout component
โ โโโ page.tsx # Main entry point
โโโ components/ # React components
โ โโโ mempool-duel/ # Game-specific components
โ โโโ Header.tsx # Game header with wallet connection
โ โโโ GameHub.tsx # Main game hub and navigation
โ โโโ CreateDuelPanel.tsx # Duel creation interface
โ โโโ DuelBoard.tsx # List of open duels
โ โโโ GameArena.tsx # Main game interface
โ โโโ MoveSelector.tsx # Move selection component
โ โโโ WaitingPhase.tsx # Encryption waiting period
โ โโโ GameResult.tsx # Game outcome display
โโโ hooks/ # Custom React hooks
โ โโโ useMempoolDuel.ts # Game logic and blockchain interactions
โโโ lib/ # Utility libraries
โ โโโ contract.ts # Contract ABIs and addresses
โ โโโ mempoolDuelContract.ts # Simplified contract interface
โโโ public/ # Static assets
โ โโโ cyberpunk-icon.svg # Game icon
โโโ README.md # This file
๐ง Configuration
Network Configuration
The game supports multiple networks with automatic detection:
// Supported networks and their configurations
const CHAIN_ID_TO_ADDRESS = {
"84532": "0xF0Fb1a485571Db8475A1271C6f7f47b695e51971", // Base Sepolia (Deployed)
"80001": "0x...", // Polygon Mumbai
"11155111": "0x..." // Ethereum Sepolia
};
Contract Deployment
To deploy your own contracts:
Compile Contracts
npx hardhat compile
Deploy to Network
npx hardhat run scripts/deploy.js --network baseSepolia
Update Environment Variables Update
.env.local
with your deployed contract addresses
Current Deployment Status โ
Base Sepolia Testnet (Chain ID: 84532)
Contract Address:
0xF0Fb1a485571Db8475A1271C6f7f47b695e51971
Blocklock Sender:
0x82Fed730CbdeC5A2D8724F2e3b316a70A565e27e
Deployment Block:
30023696
Transaction Hash:
0x36f54706e398d6da62d88c007066a125a04276c971a750d039575fe9478d6d02
Verification: โ Verified on Basescan
Gas Used:
2,398,063
gasCost:
0.000002398202087654 ETH
Contract Parameters
Min Wager:
0.001 ETH
(1,000,000,000,000,000 wei)Max Wager:
1 ETH
(1,000,000,000,000,000,000 wei)Timeout Blocks:
100
blocks
๐งช Testing
Run Tests
npm run test
# or
yarn test
Test on Testnet
Ensure you have test tokens (Base Sepolia ETH)
Connect to Base Sepolia (Chain ID: 84532) - Recommended for testing
Create a test duel with minimal wager (0.001 ETH minimum)
Test the complete game flow
Getting Base Sepolia Testnet ETH
Faucet: Base Sepolia Faucet
Alternative: Chainlink Faucet
RPC URL:
https://sepolia.base.org
๐ Deployment
Vercel (Recommended)
npm run build
vercel --prod
Other Platforms
The app can be deployed to any platform that supports Next.js:
Netlify
AWS Amplify
DigitalOcean App Platform
Self-hosted servers
๐ค Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Workflow
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature
)Commit your changes (
git commit -m 'Add amazing feature'
)Push to the branch (
git push origin feature/amazing-feature
)Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
dcipher Network - For providing the blocklock encryption infrastructure
Base Network - For testnet support and development resources
Ethereum Community - For the foundation of decentralized applications
Open Source Contributors - For the tools and libraries that make this possible
๐ Support
Documentation: docs.dcipher.network
Issues: GitHub Issues
Discussions: GitHub Discussions
Discord: Join our community
๐ฎ Roadmap
Phase 1: Core Gameplay โ
Basic game mechanics
Smart contract integration
Wallet connection
Pixel-art UI theme
Phase 2: Enhanced Features ๐ง
Tournament system
Leaderboards
NFT rewards
Mobile app
Phase 3: Advanced Features ๐
Cross-chain support
Social features
Advanced betting options
API for third-party integrations
Ready to duel? Connect your wallet and enter the arena! ๐ฎโก
Built with โค๏ธ by the Mempool Duel team
Subscribe to my newsletter
Read articles from Mohammad Hatif Osmani directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Mohammad Hatif Osmani
Mohammad Hatif Osmani
A passionate software developer who loves experimenting and learning new tech.