ColorSnap is a revolutionary decentralized puzzle game where players match colored bottles to target configurations on the blockchain. Connect your wallet, compete globally, and earn points in this engaging multi-chain experience.
๐ฎ Interactive Game Preview (Click to expand)
๐งช Current Game State: [๐ด][๐ต][๐ข][๐ก][๐ฃ]
๐ฏ Target Pattern: [๐ฃ][๐ข][๐ด][๐ต][๐ก]
Actions Available:
โโ ๐ Swap bottles โโ ๐๏ธ Peek at solution (after 5 moves)
โโ โ
Submit solution โโ ๐ซ Forfeit game
โโ ๐ Check progress โโ ๐ View leaderboard
๐โโ๏ธ Try the sequence: Swap(1,5) โ Swap(2,4) โ Swap(1,3) โ Submit!
- ๐งช Match colored bottles to hidden target patterns
- ๐ Swap bottle positions strategically
- ๐๏ธ Peek at solutions after 5 moves (with cooldown)
- ๐ Earn 10 points per completed puzzle
- ๐ Compete globally on the leaderboard
Our smart contracts are live across multiple networks for maximum accessibility:
| ๐ Network | ๐ Contract Address | ๐ Explorer | โ๏ธ Chain ID | ๐ Status |
|---|---|---|---|---|
| ๐ต Base Mainnet |
0x62dcaAdAd6D5E6CA4B594CEB636A147537aE7F8f
๐ Copy Address |
|
8453 |
๐ข LIVE |
| ๐ก Somnia Testnet |
0xc2dc20E9F389114578F78a7f3C3B071db0b8e8dC
๐ Copy Address |
|
50312 |
๐ก TESTNET |
| โก Electroneum Testnet |
0xEF7902FeE12ea3D3245eD721767FB048Afa38a2f
๐ Copy Address |
|
5201420 |
๐ต TESTNET |
๐ Quick Network Setup (Click to expand)
Base Mainnet:
Network Name: Base Mainnet
RPC URL: https://mainnet.base.org
Chain ID: 8453
Currency Symbol: ETH
Block Explorer: https://basescan.orgSomnia Testnet:
Network Name: Somnia Testnet
RPC URL: https://testnet-rpc.somnia.network
Chain ID: 50312
Currency Symbol: ETH
Block Explorer: https://shannon-explorer.somnia.networkElectroneum Testnet:
Network Name: Electroneum Testnet
RPC URL: https://testnet-rpc.electroneum.com
Chain ID: 5201420
Currency Symbol: ETN
Block Explorer: https://testnet-explorer.electroneum.com- Connect any EVM-compatible wallet
- MetaMask, WalletConnect, and more
- Seamless multi-chain support
- Set your champion name on-chain
- Persistent identity across networks
- Global recognition system
- Intuitive bottle swapping mechanics
- Real-time visual feedback
- Strategic peek system with cooldowns
- Live leaderboard updates
- Cross-network score aggregation
- Compete with players worldwide
- Works on all devices
- Mobile-optimized interface
- Smooth animations and transitions
- Live game state monitoring
- Instant transaction feedback
- Dynamic UI updates
- Node.js 18+ and npm/yarn
- Foundry (for smart contract development)
- EVM-compatible wallet
- Testnet ETH for transactions
๐ฆ Step 1: Clone & Setup Repository
# ๐ฏ Clone the repository
git clone https://github.com/7maylord/colorsnap.git
cd colorsnap
# ๐ Verify project structure
ls -la
# Expected output:
# README.md
# frontend/
# smart-contracts/โ Verification Checkpoint
Run this command to verify your setup:
echo "โ
Repository cloned successfully!" && \
echo "๐ Current directory: $(pwd)" && \
echo "๐ Files found: $(ls | wc -l) items"โ๏ธ Step 2: Smart Contract Deployment
# Navigate to smart contracts directory
cd smart-contracts
# Install Foundry dependencies
forge install
# Set your environment variables
export RPC_URL="your_rpc_url_here"
export PRIVATE_KEY="your_private_key_here"
# ๐ Deploy the contract
forge script script/Colorsnap.s.sol --rpc-url $RPC_URL --broadcast๐ Network-Specific Deployment Commands
๐ต Base Mainnet:
forge script script/Colorsnap.s.sol \
--rpc-url https://mainnet.base.org \
--private-key $PRIVATE_KEY \
--broadcast --verify๐ก Somnia Testnet:
forge script script/Colorsnap.s.sol \
--rpc-url https://testnet-rpc.somnia.network \
--private-key $PRIVATE_KEY \
--broadcastโก Electroneum Testnet:
forge script script/DeployElectroneum.s.sol \
--rpc-url https://testnet-rpc.electroneum.com \
--private-key $PRIVATE_KEY \
--broadcast๐ Contract Verification
After deployment, verify your contract:
# Get your contract address from deployment output
CONTRACT_ADDRESS="0x..." # Replace with your address
# Verify the contract is deployed
cast code $CONTRACT_ADDRESS --rpc-url $RPC_URL
# Expected: Non-empty bytecode output means success! โ
๐จ Step 3: Frontend Setup
# Navigate to frontend directory
cd ../frontend
# Install dependencies
yarn install
# or: npm install
# Create environment file
cp .env.example .env.localโ๏ธ Environment Configuration
Add these variables to your .env.local:
# ๐ Your deployed contract address
NEXT_PUBLIC_CONTRACT_ADDRESS=0x...
# ๐ RPC URL for your chosen network
NEXT_PUBLIC_RPC_URL=https://...
# โ๏ธ Chain ID for your network
NEXT_PUBLIC_CHAIN_ID=8453
# ๐ WalletConnect Project ID (get from https://cloud.walletconnect.com)
WALLETCONNECT_PROJECT_ID=your_project_id๐ Quick Copy Templates
Base Mainnet Template:
NEXT_PUBLIC_CONTRACT_ADDRESS=0x62dcaAdAd6D5E6CA4B594CEB636A147537aE7F8f
NEXT_PUBLIC_RPC_URL=https://mainnet.base.org
NEXT_PUBLIC_CHAIN_ID=8453
WALLETCONNECT_PROJECT_ID=your_project_idSomnia Testnet Template:
NEXT_PUBLIC_CONTRACT_ADDRESS=0xc2dc20E9F389114578F78a7f3C3B071db0b8e8dC
NEXT_PUBLIC_RPC_URL=https://testnet-rpc.somnia.network
NEXT_PUBLIC_CHAIN_ID=50312
WALLETCONNECT_PROJECT_ID=your_project_id# ๐ Start the development server
yarn run dev
# or: npm run dev๐ Development Server Status Check
Your development server should be running at:
- ๐ Local: http://localhost:3000
- ๐ Network: http://your-ip:3000
Verify it's working:
# Check if the server is responding
curl -I http://localhost:3000
# Expected: HTTP/200 OK โ
Common Issues & Solutions:
- โ Port 3000 in use: Try
yarn dev -p 3001 - โ Module not found: Run
yarn installagain - โ Environment vars: Check your
.env.localfile
๐ Step 4: Launch & Play!
- ๐ Open your browser to http://localhost:3000
- ๐ฆ Connect your wallet (MetaMask, WalletConnect, etc.)
- ๐ Register your champion name on-chain
- ๐ฎ Start your first game and begin matching bottles!
- โ Repository cloned and navigated
- โ๏ธ Smart contract deployed successfully
- ๐ฆ Frontend dependencies installed
- โ๏ธ Environment variables configured
- ๐ Development server running
- ๐ Application accessible in browser
- ๐ฆ Wallet connected to correct network
- ๐ Champion name registered
- ๐ฎ First game started
๐ Congratulations! You're ready to play ColorSnap!
๐ง Quick Troubleshooting
๐ซ "Cannot connect to network"
# Check your RPC URL is working
curl -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
$RPC_URL๐ซ "Transaction failed"
# Check your balance
cast balance $YOUR_WALLET_ADDRESS --rpc-url $RPC_URL
# Check gas price
cast gas-price --rpc-url $RPC_URL๐ซ "Contract not found"
# Verify contract deployment
cast code $CONTRACT_ADDRESS --rpc-url $RPC_URL
# Should return bytecode, not 0xcolorsnap/
โโโ ๐ frontend/ # Next.js Application
โ โโโ ๐ src/
โ โ โโโ ๐ components/ # React Components
โ โ โ โโโ ๐งช Bottle.tsx # Individual bottle component
โ โ โ โโโ ๐ฎ ColorSnapGame.tsx # Main game logic
โ โ โ โโโ ๐ CongratsMessage.tsx # Victory celebration
โ โ โ โโโ ๐ InstructionsModal.tsx # Game instructions
โ โ โ โโโ ๐ WalletConnectButton.tsx # Wallet integration
โ โ โ โโโ ๐ Leaderboard components
โ โ โโโ ๐ hooks/ # Custom React Hooks
โ โ โ โโโ ๐ useContractInteractions.ts # Contract calls
โ โ โ โโโ ๐ useGameCompletedListener.ts # Event listening
โ โ โ โโโ ๐ useTargetRevealLockout.ts # Peek cooldown
โ โ โโโ ๐ app/ # Next.js App Router
โ โ โ โโโ ๐ฎ game/ # Game page
โ โ โ โโโ ๐ leaderboard/ # Leaderboard page
โ โ โ โโโ ๐จ globals.css # Global styles
โ โ โโโ ๐ abi/ # Contract ABI
โ โ โโโ ๐ config/ # Configuration files
โ โ โโโ ๐ context/ # React Context providers
โ โโโ ๐ README.md # Frontend documentation
โโโ ๐ smart-contracts/ # Solidity Contracts
โ โโโ ๐ src/ # Contract Source Code
โ โ โโโ ๐ Colorsnap.sol # Main game contract
โ โโโ ๐ script/ # Deployment Scripts
โ โ โโโ ๐ Colorsnap.s.sol # Main deployment
โ โ โโโ ๐ DeployBase.s.sol # Base network deployment
โ โ โโโ โก DeployElectroneum.s.sol # Electroneum deployment
โ โโโ ๐ test/ # Contract Tests
โ โ โโโ ๐งช ColorSnap.t.sol # Test suite
โ โโโ ๐ README.md # Smart contract documentation
โโโ ๐ README.md # This documentation
๐ฏ Getting Started
- Use any EVM-compatible wallet (MetaMask, WalletConnect, etc.)
- Ensure you're connected to the correct network
- Have some testnet ETH ready for transactions
- Enter your display name (max 31 characters)
- Click "๐ Register Champion" to save it on-chain
- This name will appear on the global leaderboard
- Click "๐ฎ Start New Challenge" to begin
- Receive 5 colored bottles in random positions
- A hidden target configuration is generated
๐งช Game Mechanics
Match your bottle arrangement to the target configuration exactly. Each bottle must be in the correct position with the correct color.
| Color | Symbol | Description |
|---|---|---|
| ๐ด Red | R | The fiery starter |
| ๐ต Blue | B | The cool challenger |
| ๐ข Green | G | The nature warrior |
| ๐ก Yellow | Y | The bright contender |
| ๐ฃ Purple | P | The royal challenger |
- Select First Bottle: Click the first bottle to move
- Select Second Bottle: Click the second bottle to swap with
- Automatic Swap: Bottles exchange positions instantly
- Move Counter: Each swap counts as one move
- ๐ Locked Until 5 Moves: Must make 5 swaps to unlock
- โฑ๏ธ 3-Second Peek: View the target for 3 seconds
- ๐ 3-Minute Cooldown: Wait before next peek
- ๐ Strategic Planning: Use peeks wisely!
๐ Scoring & Strategy
- ๐ฏ 10 Points per Puzzle: Earned for each completion
- ๐ช Move Efficiency: Fewer moves = better strategy
- ๐ Global Ranking: Compete worldwide
- ๐ Permanent Storage: Points stored on-chain forever
- Start with bottles already in correct positions
- Work from outside positions inward
- Count each color to verify you have the right mix
- Don't peek too early - try solving independently first
- Recognize patterns in target arrangements
- Plan multiple swaps in advance
- Group similar colors when possible
- Focus on efficiency and fewer moves
- Memorize patterns quickly during peeks
- Work backwards from the target
- Use the "โ Matched" counter strategically
- Take time to plan - no rush penalties
๐ Game Completion
- ๐ฏ Exact Match Required: All bottles in correct positions
- ๐ 10 Points Awarded: Added to your total score
- ๐ Celebration Animation: Victory message displayed
- ๐ Instant Leaderboard Update: See your new ranking
- ๏ฟฝ No Points Lost: Existing points remain safe
- ๐ Immediate Restart: Start new game right away
- โก No Penalties: No negative consequences
- ๐ Swap Counter: Number of moves made
- โ Match Counter: Correct bottle positions
- ๐ฏ Target Display: Configuration to achieve
- โก Transaction Status: Real-time updates
๐ Development Environment Setup
- Node.js 18.0 or higher
- npm or yarn package manager
- Foundry for smart contract development
- Git for version control
# Clone the repository
git clone https://github.com/yourusername/colorsnap.git
cd colorsnap
# Install dependencies for both frontend and contracts
cd frontend && yarn install
cd ../smart-contracts && forge install
# Start development servers
cd ../frontend && yarn dev # Frontend at localhost:3000
forge test # Run contract tests๐งช Testing
cd smart-contracts
# Run all tests
forge test
# Run tests with gas reporting
forge test --gas-report
# Run specific test
forge test --match-test testGameFlowcd frontend
# Run unit tests
npm test
# Run e2e tests
npm run test:e2e
# Generate test coverage
npm run test:coverageโ๏ธ Configuration
Create .env.local in the frontend directory:
NEXT_PUBLIC_CONTRACT_ADDRESS=0x...
NEXT_PUBLIC_RPC_URL=https://...
NEXT_PUBLIC_CHAIN_ID=8453
WALLETCONNECT_PROJECT_ID=your_project_idNetworks are configured in frontend/src/config/chains.ts:
- Base Mainnet (Primary)
- Somnia Testnet
- Electroneum Testnet
๐ฆ Smart Contract Deployment
cd smart-contracts
# Set environment variables
export PRIVATE_KEY="your_private_key"
export RPC_URL="https://mainnet.base.org"
# Deploy contract
forge script script/Colorsnap.s.sol \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--broadcast \
--verify# Somnia Testnet
forge script script/Colorsnap.s.sol \
--rpc-url https://testnet-rpc.somnia.network \
--private-key $PRIVATE_KEY \
--broadcast
# Electroneum Testnet
forge script script/DeployElectroneum.s.sol \
--rpc-url https://testnet-rpc.electroneum.com \
--private-key $PRIVATE_KEY \
--broadcast๐ Frontend Deployment
# Install Vercel CLI
npm i -g vercel
# Deploy
cd frontend
vercel
# Set environment variables in Vercel dashboard
# NEXT_PUBLIC_CONTRACT_ADDRESS
# NEXT_PUBLIC_RPC_URL
# NEXT_PUBLIC_CHAIN_ID# Build the application
cd frontend
npm run build
# Deploy to Netlify
npx netlify deploy --prod --dir=out- GitHub Pages: Static export with
next export - AWS S3: Static hosting with CloudFront
- Firebase Hosting: Google's hosting platform
- IPFS: Decentralized hosting
We welcome contributions from the community! Here's how to get involved:
๐ Contribution Guidelines
- Fork the repository
- Clone your fork locally
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Test thoroughly
- Commit with clear messages:
git commit -m 'Add amazing feature' - Push to your branch:
git push origin feature/amazing-feature - Submit a pull request
- TypeScript for type safety
- ESLint for code linting
- Prettier for code formatting
- Conventional Commits for commit messages
- Comprehensive tests for new features
- ๐ฎ Game Features: New game modes, power-ups, achievements
- ๐จ UI/UX: Design improvements, animations, accessibility
- โ๏ธ Blockchain: Multi-chain support, gas optimization
- ๐ฑ Mobile: React Native app, PWA enhancements
- ๐ Documentation: Tutorials, API docs, translations
- ๐งช Testing: Unit tests, integration tests, e2e tests
MIT License
Copyright (c) 2024 ColorSnap Game
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software.
|
Source Code Contribute & Star โญ |
Updates Latest news & tips |
Community Chat & support |
|
Documentation Detailed guides |
Blog Dev insights |
Tutorials Video guides |
๐ Project Statistics
Made with โค๏ธ by the ColorSnap team
โญ Star us on GitHub if you like this project!