Skip to content

Latest commit

History

336 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ETH Shot 🎯

Node.jsSvelteKitEthers.jsSupabaseMocha+ChaiLicense: MITDeploy with VercelSepolia NetworkEthereum Mainnet

A viral Ethereum-powered game where users pay 0.0005 ETH per shot for a 1% chance to win the jackpot.

🎮 Game Overview

ETH Shot is a decentralized gambling game built on Ethereum where players take shots at winning the jackpot. Each shot costs 0.0005 ETH with a 1% chance of winning the entire pot. The game features real-time updates, social sharing, sponsor integration, and a viral referral system with discount rewards.

✨ Features

  • 🎯 Smart Contract Game: Built on Ethereum with provably fair 1% win probability
  • 💰 Dynamic Jackpot: Pot grows with each shot, 90% goes to winner
  • 🔒 Wallet Integration: Connect with MetaMask, WalletConnect, and other Web3 wallets
  • ⚡ Real-time Updates: Live pot updates and winner announcements via Supabase
  • ⏰ Cooldown System: 1-hour cooldown between shots per wallet address
  • 🎪 Sponsor Rounds: Businesses can sponsor rounds for 0.001 ETH with custom branding
  • 🎯 Referral System: Invite friends and earn discount rewards for viral growth
  • 💰 Discount Rewards: 20% discounts on shots earned through referrals with 30-day expiration
  • 📱 Social Sharing: Share wins and referral links on Twitter
  • 🎨 Winner Animations: Confetti and celebration effects for jackpot wins
  • 📊 Leaderboards: Track top players, recent winners, and referral champions
  • 📱 Responsive Design: Optimized for desktop and mobile devices

🛠 Tech Stack

Smart Contract

  • Solidity: Smart contract development
  • OpenZeppelin: Security libraries (ReentrancyGuard, Pausable, Ownable)
  • Hardhat: Development environment and testing

Frontend

  • SvelteKit: Modern web framework with SSR
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first CSS framework
  • Ethers.js v6: Ethereum interaction library
  • Web3Modal: Multi-wallet connection

Backend & Database

  • Supabase: PostgreSQL database with real-time subscriptions
  • Real-time subscriptions: Live updates for winners, shots, and sponsors

Testing & Quality

  • Mocha + Chai: JavaScript testing framework
  • Hardhat: Smart contract testing
  • ESLint + Prettier: Code formatting and linting
  • Sinon: Mocking and stubbing for tests

Deployment

  • Vercel: Frontend hosting and deployment
  • Sepolia Testnet: Ethereum testnet for testing

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • pnpm (recommended) or npm
  • MetaMask or other Web3 wallet
  • Infura/Alchemy API key
  • Supabase account

Installation

  1. Clone the repository:
git clone https://github.com/your-username/ethshot-web.git
cd ethshot-web
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
cp .env.example .env

Edit .env with your configuration:

# Smart Contract ConfigurationVITE_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890VITE_RPC_URL=https://sepolia.infura.io/v3/your-infura-key# Supabase ConfigurationVITE_SUPABASE_URL=https://your-project.supabase.coVITE_SUPABASE_ANON_KEY=your-anon-key# Application ConfigurationVITE_APP_URL=https://ethshot.ioVITE_NETWORK_NAME=Sepolia TestnetVITE_CHAIN_ID=11155111
  1. Start the development server:
pnpm dev
  1. Open http://localhost:5173 in your browser.

📋 Smart Contract

The game is powered by a Solidity smart contract with the following specifications:

Game Mechanics

  • Shot Cost: 0.0005 ETH per shot (0.0004 ETH with 20% referral discount)
  • Win Probability: 1% chance to win the jackpot
  • Payout Split: 90% to winner, 10% to contract owner
  • Cooldown Period: 1 hour (3600 seconds) between shots per wallet
  • Sponsor Cost: 0.001 ETH to sponsor a round with custom branding
  • Referral Discounts: 20% discount for both referrer and referee

Key Functions

  • takeShot(): Take a shot at the jackpot (payable)
  • sponsorRound(string name, string logoUrl): Sponsor a round (payable)
  • getCurrentPot(): Get current jackpot amount
  • getPlayerStats(address): Get player statistics
  • canTakeShot(address): Check if player can take a shot
  • getCooldownRemaining(address): Get remaining cooldown time

Security Features

  • ReentrancyGuard: Prevents reentrancy attacks
  • Pausable: Emergency pause functionality
  • Ownable: Access control for admin functions
  • Randomness: Uses block hash and timestamp for randomness

🧪 Testing

Run Smart Contract Tests

pnpm test:contracts

Run Frontend Tests

pnpm test

Run All Tests

pnpm test:all

Test Coverage

pnpm coverage

🚀 Deployment

1. Smart Contract Deployment

Deploy to Sepolia Testnet:

# Configure your private key in hardhat.config.js
pnpm deploy:testnet

Verify Contract on Etherscan:

pnpm verify:testnet

2. Database Setup

  1. Create a new Supabase project
  2. Run the SQL schema from supabase/schema.sql
  3. Configure Row Level Security (RLS) policies
  4. Update environment variables with Supabase credentials

3. Frontend Deployment

Deploy to Vercel:

# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod

Environment Variables in Vercel:

  • VITE_CONTRACT_ADDRESS
  • VITE_RPC_URL
  • VITE_SUPABASE_URL
  • VITE_SUPABASE_ANON_KEY
  • VITE_APP_URL
  • VITE_NETWORK_NAME
  • VITE_CHAIN_ID

📊 Database Schema

The application uses Supabase PostgreSQL with the following tables:

  • shots: Records all shot attempts with discount tracking
  • winners: Tracks jackpot winners
  • sponsors: Manages sponsorship rounds
  • players: Player statistics and rankings
  • referral_codes: User referral codes for viral growth
  • referrals: Tracks referral relationships
  • referral_discounts: Manages discount rewards and usage

Real-time subscriptions provide live updates for:

  • New winners
  • Shot attempts
  • Sponsor activations

🎨 Components

Core Components

  • GameButton: Main "Take the Shot" button with loading states
  • PotDisplay: Real-time jackpot amount display
  • WalletConnect: Multi-wallet connection interface
  • WinnerAnimation: Confetti and celebration effects
  • Leaderboard: Top players and statistics
  • RecentWinners: Live winner feed
  • SponsorBanner: Sponsor branding display
  • ReferralSystem: Referral code management and sharing
  • DiscountButton: Apply referral discounts to shots
  • ReferralLeaderboard: Top referrers and statistics

Stores (State Management)

  • gameStore: Game state, contract interactions, database integration
  • walletStore: Wallet connection and Web3 functionality
  • toastStore: User notifications and feedback

🔧 Development Scripts

# Development
pnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production build# Testing
pnpm test# Run frontend tests
pnpm test:contracts # Run smart contract tests
pnpm test:all # Run all tests
pnpm coverage # Generate test coverage# Smart Contract
pnpm compile # Compile contracts
pnpm deploy:testnet # Deploy to Sepolia
pnpm verify:testnet # Verify on Etherscan# Code Quality
pnpm lint # Run ESLint
pnpm format # Format with Prettier

🚨 Security Considerations

Smart Contract Security

  • Audited Libraries: Uses OpenZeppelin's battle-tested contracts
  • Reentrancy Protection: ReentrancyGuard prevents reentrancy attacks
  • Access Control: Ownable pattern for admin functions
  • Emergency Pause: Pausable functionality for emergency stops
  • Input Validation: Proper validation of all inputs

Frontend Security

  • Environment Variables: Sensitive data stored in environment variables
  • HTTPS Only: All production traffic over HTTPS
  • Content Security Policy: Implemented via Vercel headers
  • XSS Protection: Framework-level XSS protection

📈 Performance Optimizations

  • Database Indexing: Optimized queries with proper indexes
  • Real-time Subscriptions: Efficient WebSocket connections
  • Caching: Strategic caching of contract calls
  • Code Splitting: Lazy loading of components
  • Image Optimization: Optimized assets and images

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite: pnpm test:all
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Submit a pull request

Development Guidelines

  • Follow the existing code style
  • Write tests for new features
  • Update documentation as needed
  • Use conventional commit messages

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

Important: This is a game of chance involving real cryptocurrency. Please consider the following:

  • Gambling Risk: Only gamble with funds you can afford to lose
  • Smart Contract Risk: Smart contracts may contain bugs or vulnerabilities
  • Regulatory Compliance: Ensure compliance with local gambling laws
  • No Guarantees: No guarantees of winnings or returns
  • Educational Purpose: This project is primarily for educational purposes

🆘 Support

  • Documentation: Check this README and inline code comments
  • Issues: Report bugs via GitHub Issues
  • Discussions: Join discussions in GitHub Discussions
  • Community: Follow updates on Twitter @profullstackinc
  • Discord: Join our community on Discord

🎯 Roadmap

Phase 1 (Current)

  • Core game mechanics
  • Smart contract deployment
  • Frontend application
  • Database integration
  • Real-time updates

Phase 2 (Planned)

  • Mobile app development
  • Advanced analytics dashboard
  • NFT rewards for winners
  • Referral system with discount rewards
  • Multiple game modes

Phase 3 (Future)

  • Layer 2 integration (Polygon, Arbitrum)
  • DAO governance
  • Tournament system
  • Cross-chain compatibility

Built with ❤️ by the ETH Shot team

About

A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - profullstack/ethshot-web: A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot. · GitHub
Skip to content

Latest commit

History

336 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ETH Shot 🎯

Node.jsSvelteKitEthers.jsSupabaseMocha+ChaiLicense: MITDeploy with VercelSepolia NetworkEthereum Mainnet

A viral Ethereum-powered game where users pay 0.0005 ETH per shot for a 1% chance to win the jackpot.

🎮 Game Overview

ETH Shot is a decentralized gambling game built on Ethereum where players take shots at winning the jackpot. Each shot costs 0.0005 ETH with a 1% chance of winning the entire pot. The game features real-time updates, social sharing, sponsor integration, and a viral referral system with discount rewards.

✨ Features

  • 🎯 Smart Contract Game: Built on Ethereum with provably fair 1% win probability
  • 💰 Dynamic Jackpot: Pot grows with each shot, 90% goes to winner
  • 🔒 Wallet Integration: Connect with MetaMask, WalletConnect, and other Web3 wallets
  • ⚡ Real-time Updates: Live pot updates and winner announcements via Supabase
  • ⏰ Cooldown System: 1-hour cooldown between shots per wallet address
  • 🎪 Sponsor Rounds: Businesses can sponsor rounds for 0.001 ETH with custom branding
  • 🎯 Referral System: Invite friends and earn discount rewards for viral growth
  • 💰 Discount Rewards: 20% discounts on shots earned through referrals with 30-day expiration
  • 📱 Social Sharing: Share wins and referral links on Twitter
  • 🎨 Winner Animations: Confetti and celebration effects for jackpot wins
  • 📊 Leaderboards: Track top players, recent winners, and referral champions
  • 📱 Responsive Design: Optimized for desktop and mobile devices

🛠 Tech Stack

Smart Contract

  • Solidity: Smart contract development
  • OpenZeppelin: Security libraries (ReentrancyGuard, Pausable, Ownable)
  • Hardhat: Development environment and testing

Frontend

  • SvelteKit: Modern web framework with SSR
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first CSS framework
  • Ethers.js v6: Ethereum interaction library
  • Web3Modal: Multi-wallet connection

Backend & Database

  • Supabase: PostgreSQL database with real-time subscriptions
  • Real-time subscriptions: Live updates for winners, shots, and sponsors

Testing & Quality

  • Mocha + Chai: JavaScript testing framework
  • Hardhat: Smart contract testing
  • ESLint + Prettier: Code formatting and linting
  • Sinon: Mocking and stubbing for tests

Deployment

  • Vercel: Frontend hosting and deployment
  • Sepolia Testnet: Ethereum testnet for testing

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • pnpm (recommended) or npm
  • MetaMask or other Web3 wallet
  • Infura/Alchemy API key
  • Supabase account

Installation

  1. Clone the repository:
git clone https://github.com/your-username/ethshot-web.git
cd ethshot-web
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
cp .env.example .env

Edit .env with your configuration:

# Smart Contract ConfigurationVITE_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890VITE_RPC_URL=https://sepolia.infura.io/v3/your-infura-key# Supabase ConfigurationVITE_SUPABASE_URL=https://your-project.supabase.coVITE_SUPABASE_ANON_KEY=your-anon-key# Application ConfigurationVITE_APP_URL=https://ethshot.ioVITE_NETWORK_NAME=Sepolia TestnetVITE_CHAIN_ID=11155111
  1. Start the development server:
pnpm dev
  1. Open http://localhost:5173 in your browser.

📋 Smart Contract

The game is powered by a Solidity smart contract with the following specifications:

Game Mechanics

  • Shot Cost: 0.0005 ETH per shot (0.0004 ETH with 20% referral discount)
  • Win Probability: 1% chance to win the jackpot
  • Payout Split: 90% to winner, 10% to contract owner
  • Cooldown Period: 1 hour (3600 seconds) between shots per wallet
  • Sponsor Cost: 0.001 ETH to sponsor a round with custom branding
  • Referral Discounts: 20% discount for both referrer and referee

Key Functions

  • takeShot(): Take a shot at the jackpot (payable)
  • sponsorRound(string name, string logoUrl): Sponsor a round (payable)
  • getCurrentPot(): Get current jackpot amount
  • getPlayerStats(address): Get player statistics
  • canTakeShot(address): Check if player can take a shot
  • getCooldownRemaining(address): Get remaining cooldown time

Security Features

  • ReentrancyGuard: Prevents reentrancy attacks
  • Pausable: Emergency pause functionality
  • Ownable: Access control for admin functions
  • Randomness: Uses block hash and timestamp for randomness

🧪 Testing

Run Smart Contract Tests

pnpm test:contracts

Run Frontend Tests

pnpm test

Run All Tests

pnpm test:all

Test Coverage

pnpm coverage

🚀 Deployment

1. Smart Contract Deployment

Deploy to Sepolia Testnet:

# Configure your private key in hardhat.config.js
pnpm deploy:testnet

Verify Contract on Etherscan:

pnpm verify:testnet

2. Database Setup

  1. Create a new Supabase project
  2. Run the SQL schema from supabase/schema.sql
  3. Configure Row Level Security (RLS) policies
  4. Update environment variables with Supabase credentials

3. Frontend Deployment

Deploy to Vercel:

# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod

Environment Variables in Vercel:

  • VITE_CONTRACT_ADDRESS
  • VITE_RPC_URL
  • VITE_SUPABASE_URL
  • VITE_SUPABASE_ANON_KEY
  • VITE_APP_URL
  • VITE_NETWORK_NAME
  • VITE_CHAIN_ID

📊 Database Schema

The application uses Supabase PostgreSQL with the following tables:

  • shots: Records all shot attempts with discount tracking
  • winners: Tracks jackpot winners
  • sponsors: Manages sponsorship rounds
  • players: Player statistics and rankings
  • referral_codes: User referral codes for viral growth
  • referrals: Tracks referral relationships
  • referral_discounts: Manages discount rewards and usage

Real-time subscriptions provide live updates for:

  • New winners
  • Shot attempts
  • Sponsor activations

🎨 Components

Core Components

  • GameButton: Main "Take the Shot" button with loading states
  • PotDisplay: Real-time jackpot amount display
  • WalletConnect: Multi-wallet connection interface
  • WinnerAnimation: Confetti and celebration effects
  • Leaderboard: Top players and statistics
  • RecentWinners: Live winner feed
  • SponsorBanner: Sponsor branding display
  • ReferralSystem: Referral code management and sharing
  • DiscountButton: Apply referral discounts to shots
  • ReferralLeaderboard: Top referrers and statistics

Stores (State Management)

  • gameStore: Game state, contract interactions, database integration
  • walletStore: Wallet connection and Web3 functionality
  • toastStore: User notifications and feedback

🔧 Development Scripts

# Development
pnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production build# Testing
pnpm test# Run frontend tests
pnpm test:contracts # Run smart contract tests
pnpm test:all # Run all tests
pnpm coverage # Generate test coverage# Smart Contract
pnpm compile # Compile contracts
pnpm deploy:testnet # Deploy to Sepolia
pnpm verify:testnet # Verify on Etherscan# Code Quality
pnpm lint # Run ESLint
pnpm format # Format with Prettier

🚨 Security Considerations

Smart Contract Security

  • Audited Libraries: Uses OpenZeppelin's battle-tested contracts
  • Reentrancy Protection: ReentrancyGuard prevents reentrancy attacks
  • Access Control: Ownable pattern for admin functions
  • Emergency Pause: Pausable functionality for emergency stops
  • Input Validation: Proper validation of all inputs

Frontend Security

  • Environment Variables: Sensitive data stored in environment variables
  • HTTPS Only: All production traffic over HTTPS
  • Content Security Policy: Implemented via Vercel headers
  • XSS Protection: Framework-level XSS protection

📈 Performance Optimizations

  • Database Indexing: Optimized queries with proper indexes
  • Real-time Subscriptions: Efficient WebSocket connections
  • Caching: Strategic caching of contract calls
  • Code Splitting: Lazy loading of components
  • Image Optimization: Optimized assets and images

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite: pnpm test:all
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Submit a pull request

Development Guidelines

  • Follow the existing code style
  • Write tests for new features
  • Update documentation as needed
  • Use conventional commit messages

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

Important: This is a game of chance involving real cryptocurrency. Please consider the following:

  • Gambling Risk: Only gamble with funds you can afford to lose
  • Smart Contract Risk: Smart contracts may contain bugs or vulnerabilities
  • Regulatory Compliance: Ensure compliance with local gambling laws
  • No Guarantees: No guarantees of winnings or returns
  • Educational Purpose: This project is primarily for educational purposes

🆘 Support

  • Documentation: Check this README and inline code comments
  • Issues: Report bugs via GitHub Issues
  • Discussions: Join discussions in GitHub Discussions
  • Community: Follow updates on Twitter @profullstackinc
  • Discord: Join our community on Discord

🎯 Roadmap

Phase 1 (Current)

  • Core game mechanics
  • Smart contract deployment
  • Frontend application
  • Database integration
  • Real-time updates

Phase 2 (Planned)

  • Mobile app development
  • Advanced analytics dashboard
  • NFT rewards for winners
  • Referral system with discount rewards
  • Multiple game modes

Phase 3 (Future)

  • Layer 2 integration (Polygon, Arbitrum)
  • DAO governance
  • Tournament system
  • Cross-chain compatibility

Built with ❤️ by the ETH Shot team

About

A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - profullstack/ethshot-web: A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot. · GitHub
Skip to content

Latest commit

History

336 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ETH Shot 🎯

Node.jsSvelteKitEthers.jsSupabaseMocha+ChaiLicense: MITDeploy with VercelSepolia NetworkEthereum Mainnet

A viral Ethereum-powered game where users pay 0.0005 ETH per shot for a 1% chance to win the jackpot.

🎮 Game Overview

ETH Shot is a decentralized gambling game built on Ethereum where players take shots at winning the jackpot. Each shot costs 0.0005 ETH with a 1% chance of winning the entire pot. The game features real-time updates, social sharing, sponsor integration, and a viral referral system with discount rewards.

✨ Features

  • 🎯 Smart Contract Game: Built on Ethereum with provably fair 1% win probability
  • 💰 Dynamic Jackpot: Pot grows with each shot, 90% goes to winner
  • 🔒 Wallet Integration: Connect with MetaMask, WalletConnect, and other Web3 wallets
  • ⚡ Real-time Updates: Live pot updates and winner announcements via Supabase
  • ⏰ Cooldown System: 1-hour cooldown between shots per wallet address
  • 🎪 Sponsor Rounds: Businesses can sponsor rounds for 0.001 ETH with custom branding
  • 🎯 Referral System: Invite friends and earn discount rewards for viral growth
  • 💰 Discount Rewards: 20% discounts on shots earned through referrals with 30-day expiration
  • 📱 Social Sharing: Share wins and referral links on Twitter
  • 🎨 Winner Animations: Confetti and celebration effects for jackpot wins
  • 📊 Leaderboards: Track top players, recent winners, and referral champions
  • 📱 Responsive Design: Optimized for desktop and mobile devices

🛠 Tech Stack

Smart Contract

  • Solidity: Smart contract development
  • OpenZeppelin: Security libraries (ReentrancyGuard, Pausable, Ownable)
  • Hardhat: Development environment and testing

Frontend

  • SvelteKit: Modern web framework with SSR
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first CSS framework
  • Ethers.js v6: Ethereum interaction library
  • Web3Modal: Multi-wallet connection

Backend & Database

  • Supabase: PostgreSQL database with real-time subscriptions
  • Real-time subscriptions: Live updates for winners, shots, and sponsors

Testing & Quality

  • Mocha + Chai: JavaScript testing framework
  • Hardhat: Smart contract testing
  • ESLint + Prettier: Code formatting and linting
  • Sinon: Mocking and stubbing for tests

Deployment

  • Vercel: Frontend hosting and deployment
  • Sepolia Testnet: Ethereum testnet for testing

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • pnpm (recommended) or npm
  • MetaMask or other Web3 wallet
  • Infura/Alchemy API key
  • Supabase account

Installation

  1. Clone the repository:
git clone https://github.com/your-username/ethshot-web.git
cd ethshot-web
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
cp .env.example .env

Edit .env with your configuration:

# Smart Contract ConfigurationVITE_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890VITE_RPC_URL=https://sepolia.infura.io/v3/your-infura-key# Supabase ConfigurationVITE_SUPABASE_URL=https://your-project.supabase.coVITE_SUPABASE_ANON_KEY=your-anon-key# Application ConfigurationVITE_APP_URL=https://ethshot.ioVITE_NETWORK_NAME=Sepolia TestnetVITE_CHAIN_ID=11155111
  1. Start the development server:
pnpm dev
  1. Open http://localhost:5173 in your browser.

📋 Smart Contract

The game is powered by a Solidity smart contract with the following specifications:

Game Mechanics

  • Shot Cost: 0.0005 ETH per shot (0.0004 ETH with 20% referral discount)
  • Win Probability: 1% chance to win the jackpot
  • Payout Split: 90% to winner, 10% to contract owner
  • Cooldown Period: 1 hour (3600 seconds) between shots per wallet
  • Sponsor Cost: 0.001 ETH to sponsor a round with custom branding
  • Referral Discounts: 20% discount for both referrer and referee

Key Functions

  • takeShot(): Take a shot at the jackpot (payable)
  • sponsorRound(string name, string logoUrl): Sponsor a round (payable)
  • getCurrentPot(): Get current jackpot amount
  • getPlayerStats(address): Get player statistics
  • canTakeShot(address): Check if player can take a shot
  • getCooldownRemaining(address): Get remaining cooldown time

Security Features

  • ReentrancyGuard: Prevents reentrancy attacks
  • Pausable: Emergency pause functionality
  • Ownable: Access control for admin functions
  • Randomness: Uses block hash and timestamp for randomness

🧪 Testing

Run Smart Contract Tests

pnpm test:contracts

Run Frontend Tests

pnpm test

Run All Tests

pnpm test:all

Test Coverage

pnpm coverage

🚀 Deployment

1. Smart Contract Deployment

Deploy to Sepolia Testnet:

# Configure your private key in hardhat.config.js
pnpm deploy:testnet

Verify Contract on Etherscan:

pnpm verify:testnet

2. Database Setup

  1. Create a new Supabase project
  2. Run the SQL schema from supabase/schema.sql
  3. Configure Row Level Security (RLS) policies
  4. Update environment variables with Supabase credentials

3. Frontend Deployment

Deploy to Vercel:

# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod

Environment Variables in Vercel:

  • VITE_CONTRACT_ADDRESS
  • VITE_RPC_URL
  • VITE_SUPABASE_URL
  • VITE_SUPABASE_ANON_KEY
  • VITE_APP_URL
  • VITE_NETWORK_NAME
  • VITE_CHAIN_ID

📊 Database Schema

The application uses Supabase PostgreSQL with the following tables:

  • shots: Records all shot attempts with discount tracking
  • winners: Tracks jackpot winners
  • sponsors: Manages sponsorship rounds
  • players: Player statistics and rankings
  • referral_codes: User referral codes for viral growth
  • referrals: Tracks referral relationships
  • referral_discounts: Manages discount rewards and usage

Real-time subscriptions provide live updates for:

  • New winners
  • Shot attempts
  • Sponsor activations

🎨 Components

Core Components

  • GameButton: Main "Take the Shot" button with loading states
  • PotDisplay: Real-time jackpot amount display
  • WalletConnect: Multi-wallet connection interface
  • WinnerAnimation: Confetti and celebration effects
  • Leaderboard: Top players and statistics
  • RecentWinners: Live winner feed
  • SponsorBanner: Sponsor branding display
  • ReferralSystem: Referral code management and sharing
  • DiscountButton: Apply referral discounts to shots
  • ReferralLeaderboard: Top referrers and statistics

Stores (State Management)

  • gameStore: Game state, contract interactions, database integration
  • walletStore: Wallet connection and Web3 functionality
  • toastStore: User notifications and feedback

🔧 Development Scripts

# Development
pnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production build# Testing
pnpm test# Run frontend tests
pnpm test:contracts # Run smart contract tests
pnpm test:all # Run all tests
pnpm coverage # Generate test coverage# Smart Contract
pnpm compile # Compile contracts
pnpm deploy:testnet # Deploy to Sepolia
pnpm verify:testnet # Verify on Etherscan# Code Quality
pnpm lint # Run ESLint
pnpm format # Format with Prettier

🚨 Security Considerations

Smart Contract Security

  • Audited Libraries: Uses OpenZeppelin's battle-tested contracts
  • Reentrancy Protection: ReentrancyGuard prevents reentrancy attacks
  • Access Control: Ownable pattern for admin functions
  • Emergency Pause: Pausable functionality for emergency stops
  • Input Validation: Proper validation of all inputs

Frontend Security

  • Environment Variables: Sensitive data stored in environment variables
  • HTTPS Only: All production traffic over HTTPS
  • Content Security Policy: Implemented via Vercel headers
  • XSS Protection: Framework-level XSS protection

📈 Performance Optimizations

  • Database Indexing: Optimized queries with proper indexes
  • Real-time Subscriptions: Efficient WebSocket connections
  • Caching: Strategic caching of contract calls
  • Code Splitting: Lazy loading of components
  • Image Optimization: Optimized assets and images

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite: pnpm test:all
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Submit a pull request

Development Guidelines

  • Follow the existing code style
  • Write tests for new features
  • Update documentation as needed
  • Use conventional commit messages

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

Important: This is a game of chance involving real cryptocurrency. Please consider the following:

  • Gambling Risk: Only gamble with funds you can afford to lose
  • Smart Contract Risk: Smart contracts may contain bugs or vulnerabilities
  • Regulatory Compliance: Ensure compliance with local gambling laws
  • No Guarantees: No guarantees of winnings or returns
  • Educational Purpose: This project is primarily for educational purposes

🆘 Support

  • Documentation: Check this README and inline code comments
  • Issues: Report bugs via GitHub Issues
  • Discussions: Join discussions in GitHub Discussions
  • Community: Follow updates on Twitter @profullstackinc
  • Discord: Join our community on Discord

🎯 Roadmap

Phase 1 (Current)

  • Core game mechanics
  • Smart contract deployment
  • Frontend application
  • Database integration
  • Real-time updates

Phase 2 (Planned)

  • Mobile app development
  • Advanced analytics dashboard
  • NFT rewards for winners
  • Referral system with discount rewards
  • Multiple game modes

Phase 3 (Future)

  • Layer 2 integration (Polygon, Arbitrum)
  • DAO governance
  • Tournament system
  • Cross-chain compatibility

Built with ❤️ by the ETH Shot team

About

A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - profullstack/ethshot-web: A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot. · GitHub
Skip to content

Latest commit

History

336 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ETH Shot 🎯

Node.jsSvelteKitEthers.jsSupabaseMocha+ChaiLicense: MITDeploy with VercelSepolia NetworkEthereum Mainnet

A viral Ethereum-powered game where users pay 0.0005 ETH per shot for a 1% chance to win the jackpot.

🎮 Game Overview

ETH Shot is a decentralized gambling game built on Ethereum where players take shots at winning the jackpot. Each shot costs 0.0005 ETH with a 1% chance of winning the entire pot. The game features real-time updates, social sharing, sponsor integration, and a viral referral system with discount rewards.

✨ Features

  • 🎯 Smart Contract Game: Built on Ethereum with provably fair 1% win probability
  • 💰 Dynamic Jackpot: Pot grows with each shot, 90% goes to winner
  • 🔒 Wallet Integration: Connect with MetaMask, WalletConnect, and other Web3 wallets
  • ⚡ Real-time Updates: Live pot updates and winner announcements via Supabase
  • ⏰ Cooldown System: 1-hour cooldown between shots per wallet address
  • 🎪 Sponsor Rounds: Businesses can sponsor rounds for 0.001 ETH with custom branding
  • 🎯 Referral System: Invite friends and earn discount rewards for viral growth
  • 💰 Discount Rewards: 20% discounts on shots earned through referrals with 30-day expiration
  • 📱 Social Sharing: Share wins and referral links on Twitter
  • 🎨 Winner Animations: Confetti and celebration effects for jackpot wins
  • 📊 Leaderboards: Track top players, recent winners, and referral champions
  • 📱 Responsive Design: Optimized for desktop and mobile devices

🛠 Tech Stack

Smart Contract

  • Solidity: Smart contract development
  • OpenZeppelin: Security libraries (ReentrancyGuard, Pausable, Ownable)
  • Hardhat: Development environment and testing

Frontend

  • SvelteKit: Modern web framework with SSR
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first CSS framework
  • Ethers.js v6: Ethereum interaction library
  • Web3Modal: Multi-wallet connection

Backend & Database

  • Supabase: PostgreSQL database with real-time subscriptions
  • Real-time subscriptions: Live updates for winners, shots, and sponsors

Testing & Quality

  • Mocha + Chai: JavaScript testing framework
  • Hardhat: Smart contract testing
  • ESLint + Prettier: Code formatting and linting
  • Sinon: Mocking and stubbing for tests

Deployment

  • Vercel: Frontend hosting and deployment
  • Sepolia Testnet: Ethereum testnet for testing

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • pnpm (recommended) or npm
  • MetaMask or other Web3 wallet
  • Infura/Alchemy API key
  • Supabase account

Installation

  1. Clone the repository:
git clone https://github.com/your-username/ethshot-web.git
cd ethshot-web
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
cp .env.example .env

Edit .env with your configuration:

# Smart Contract ConfigurationVITE_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890VITE_RPC_URL=https://sepolia.infura.io/v3/your-infura-key# Supabase ConfigurationVITE_SUPABASE_URL=https://your-project.supabase.coVITE_SUPABASE_ANON_KEY=your-anon-key# Application ConfigurationVITE_APP_URL=https://ethshot.ioVITE_NETWORK_NAME=Sepolia TestnetVITE_CHAIN_ID=11155111
  1. Start the development server:
pnpm dev
  1. Open http://localhost:5173 in your browser.

📋 Smart Contract

The game is powered by a Solidity smart contract with the following specifications:

Game Mechanics

  • Shot Cost: 0.0005 ETH per shot (0.0004 ETH with 20% referral discount)
  • Win Probability: 1% chance to win the jackpot
  • Payout Split: 90% to winner, 10% to contract owner
  • Cooldown Period: 1 hour (3600 seconds) between shots per wallet
  • Sponsor Cost: 0.001 ETH to sponsor a round with custom branding
  • Referral Discounts: 20% discount for both referrer and referee

Key Functions

  • takeShot(): Take a shot at the jackpot (payable)
  • sponsorRound(string name, string logoUrl): Sponsor a round (payable)
  • getCurrentPot(): Get current jackpot amount
  • getPlayerStats(address): Get player statistics
  • canTakeShot(address): Check if player can take a shot
  • getCooldownRemaining(address): Get remaining cooldown time

Security Features

  • ReentrancyGuard: Prevents reentrancy attacks
  • Pausable: Emergency pause functionality
  • Ownable: Access control for admin functions
  • Randomness: Uses block hash and timestamp for randomness

🧪 Testing

Run Smart Contract Tests

pnpm test:contracts

Run Frontend Tests

pnpm test

Run All Tests

pnpm test:all

Test Coverage

pnpm coverage

🚀 Deployment

1. Smart Contract Deployment

Deploy to Sepolia Testnet:

# Configure your private key in hardhat.config.js
pnpm deploy:testnet

Verify Contract on Etherscan:

pnpm verify:testnet

2. Database Setup

  1. Create a new Supabase project
  2. Run the SQL schema from supabase/schema.sql
  3. Configure Row Level Security (RLS) policies
  4. Update environment variables with Supabase credentials

3. Frontend Deployment

Deploy to Vercel:

# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod

Environment Variables in Vercel:

  • VITE_CONTRACT_ADDRESS
  • VITE_RPC_URL
  • VITE_SUPABASE_URL
  • VITE_SUPABASE_ANON_KEY
  • VITE_APP_URL
  • VITE_NETWORK_NAME
  • VITE_CHAIN_ID

📊 Database Schema

The application uses Supabase PostgreSQL with the following tables:

  • shots: Records all shot attempts with discount tracking
  • winners: Tracks jackpot winners
  • sponsors: Manages sponsorship rounds
  • players: Player statistics and rankings
  • referral_codes: User referral codes for viral growth
  • referrals: Tracks referral relationships
  • referral_discounts: Manages discount rewards and usage

Real-time subscriptions provide live updates for:

  • New winners
  • Shot attempts
  • Sponsor activations

🎨 Components

Core Components

  • GameButton: Main "Take the Shot" button with loading states
  • PotDisplay: Real-time jackpot amount display
  • WalletConnect: Multi-wallet connection interface
  • WinnerAnimation: Confetti and celebration effects
  • Leaderboard: Top players and statistics
  • RecentWinners: Live winner feed
  • SponsorBanner: Sponsor branding display
  • ReferralSystem: Referral code management and sharing
  • DiscountButton: Apply referral discounts to shots
  • ReferralLeaderboard: Top referrers and statistics

Stores (State Management)

  • gameStore: Game state, contract interactions, database integration
  • walletStore: Wallet connection and Web3 functionality
  • toastStore: User notifications and feedback

🔧 Development Scripts

# Development
pnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production build# Testing
pnpm test# Run frontend tests
pnpm test:contracts # Run smart contract tests
pnpm test:all # Run all tests
pnpm coverage # Generate test coverage# Smart Contract
pnpm compile # Compile contracts
pnpm deploy:testnet # Deploy to Sepolia
pnpm verify:testnet # Verify on Etherscan# Code Quality
pnpm lint # Run ESLint
pnpm format # Format with Prettier

🚨 Security Considerations

Smart Contract Security

  • Audited Libraries: Uses OpenZeppelin's battle-tested contracts
  • Reentrancy Protection: ReentrancyGuard prevents reentrancy attacks
  • Access Control: Ownable pattern for admin functions
  • Emergency Pause: Pausable functionality for emergency stops
  • Input Validation: Proper validation of all inputs

Frontend Security

  • Environment Variables: Sensitive data stored in environment variables
  • HTTPS Only: All production traffic over HTTPS
  • Content Security Policy: Implemented via Vercel headers
  • XSS Protection: Framework-level XSS protection

📈 Performance Optimizations

  • Database Indexing: Optimized queries with proper indexes
  • Real-time Subscriptions: Efficient WebSocket connections
  • Caching: Strategic caching of contract calls
  • Code Splitting: Lazy loading of components
  • Image Optimization: Optimized assets and images

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite: pnpm test:all
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Submit a pull request

Development Guidelines

  • Follow the existing code style
  • Write tests for new features
  • Update documentation as needed
  • Use conventional commit messages

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

Important: This is a game of chance involving real cryptocurrency. Please consider the following:

  • Gambling Risk: Only gamble with funds you can afford to lose
  • Smart Contract Risk: Smart contracts may contain bugs or vulnerabilities
  • Regulatory Compliance: Ensure compliance with local gambling laws
  • No Guarantees: No guarantees of winnings or returns
  • Educational Purpose: This project is primarily for educational purposes

🆘 Support

  • Documentation: Check this README and inline code comments
  • Issues: Report bugs via GitHub Issues
  • Discussions: Join discussions in GitHub Discussions
  • Community: Follow updates on Twitter @profullstackinc
  • Discord: Join our community on Discord

🎯 Roadmap

Phase 1 (Current)

  • Core game mechanics
  • Smart contract deployment
  • Frontend application
  • Database integration
  • Real-time updates

Phase 2 (Planned)

  • Mobile app development
  • Advanced analytics dashboard
  • NFT rewards for winners
  • Referral system with discount rewards
  • Multiple game modes

Phase 3 (Future)

  • Layer 2 integration (Polygon, Arbitrum)
  • DAO governance
  • Tournament system
  • Cross-chain compatibility

Built with ❤️ by the ETH Shot team

About

A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - profullstack/ethshot-web: A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot. · GitHub
Skip to content

Latest commit

History

336 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ETH Shot 🎯

Node.jsSvelteKitEthers.jsSupabaseMocha+ChaiLicense: MITDeploy with VercelSepolia NetworkEthereum Mainnet

A viral Ethereum-powered game where users pay 0.0005 ETH per shot for a 1% chance to win the jackpot.

🎮 Game Overview

ETH Shot is a decentralized gambling game built on Ethereum where players take shots at winning the jackpot. Each shot costs 0.0005 ETH with a 1% chance of winning the entire pot. The game features real-time updates, social sharing, sponsor integration, and a viral referral system with discount rewards.

✨ Features

  • 🎯 Smart Contract Game: Built on Ethereum with provably fair 1% win probability
  • 💰 Dynamic Jackpot: Pot grows with each shot, 90% goes to winner
  • 🔒 Wallet Integration: Connect with MetaMask, WalletConnect, and other Web3 wallets
  • ⚡ Real-time Updates: Live pot updates and winner announcements via Supabase
  • ⏰ Cooldown System: 1-hour cooldown between shots per wallet address
  • 🎪 Sponsor Rounds: Businesses can sponsor rounds for 0.001 ETH with custom branding
  • 🎯 Referral System: Invite friends and earn discount rewards for viral growth
  • 💰 Discount Rewards: 20% discounts on shots earned through referrals with 30-day expiration
  • 📱 Social Sharing: Share wins and referral links on Twitter
  • 🎨 Winner Animations: Confetti and celebration effects for jackpot wins
  • 📊 Leaderboards: Track top players, recent winners, and referral champions
  • 📱 Responsive Design: Optimized for desktop and mobile devices

🛠 Tech Stack

Smart Contract

  • Solidity: Smart contract development
  • OpenZeppelin: Security libraries (ReentrancyGuard, Pausable, Ownable)
  • Hardhat: Development environment and testing

Frontend

  • SvelteKit: Modern web framework with SSR
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first CSS framework
  • Ethers.js v6: Ethereum interaction library
  • Web3Modal: Multi-wallet connection

Backend & Database

  • Supabase: PostgreSQL database with real-time subscriptions
  • Real-time subscriptions: Live updates for winners, shots, and sponsors

Testing & Quality

  • Mocha + Chai: JavaScript testing framework
  • Hardhat: Smart contract testing
  • ESLint + Prettier: Code formatting and linting
  • Sinon: Mocking and stubbing for tests

Deployment

  • Vercel: Frontend hosting and deployment
  • Sepolia Testnet: Ethereum testnet for testing

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • pnpm (recommended) or npm
  • MetaMask or other Web3 wallet
  • Infura/Alchemy API key
  • Supabase account

Installation

  1. Clone the repository:
git clone https://github.com/your-username/ethshot-web.git
cd ethshot-web
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
cp .env.example .env

Edit .env with your configuration:

# Smart Contract ConfigurationVITE_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890VITE_RPC_URL=https://sepolia.infura.io/v3/your-infura-key# Supabase ConfigurationVITE_SUPABASE_URL=https://your-project.supabase.coVITE_SUPABASE_ANON_KEY=your-anon-key# Application ConfigurationVITE_APP_URL=https://ethshot.ioVITE_NETWORK_NAME=Sepolia TestnetVITE_CHAIN_ID=11155111
  1. Start the development server:
pnpm dev
  1. Open http://localhost:5173 in your browser.

📋 Smart Contract

The game is powered by a Solidity smart contract with the following specifications:

Game Mechanics

  • Shot Cost: 0.0005 ETH per shot (0.0004 ETH with 20% referral discount)
  • Win Probability: 1% chance to win the jackpot
  • Payout Split: 90% to winner, 10% to contract owner
  • Cooldown Period: 1 hour (3600 seconds) between shots per wallet
  • Sponsor Cost: 0.001 ETH to sponsor a round with custom branding
  • Referral Discounts: 20% discount for both referrer and referee

Key Functions

  • takeShot(): Take a shot at the jackpot (payable)
  • sponsorRound(string name, string logoUrl): Sponsor a round (payable)
  • getCurrentPot(): Get current jackpot amount
  • getPlayerStats(address): Get player statistics
  • canTakeShot(address): Check if player can take a shot
  • getCooldownRemaining(address): Get remaining cooldown time

Security Features

  • ReentrancyGuard: Prevents reentrancy attacks
  • Pausable: Emergency pause functionality
  • Ownable: Access control for admin functions
  • Randomness: Uses block hash and timestamp for randomness

🧪 Testing

Run Smart Contract Tests

pnpm test:contracts

Run Frontend Tests

pnpm test

Run All Tests

pnpm test:all

Test Coverage

pnpm coverage

🚀 Deployment

1. Smart Contract Deployment

Deploy to Sepolia Testnet:

# Configure your private key in hardhat.config.js
pnpm deploy:testnet

Verify Contract on Etherscan:

pnpm verify:testnet

2. Database Setup

  1. Create a new Supabase project
  2. Run the SQL schema from supabase/schema.sql
  3. Configure Row Level Security (RLS) policies
  4. Update environment variables with Supabase credentials

3. Frontend Deployment

Deploy to Vercel:

# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod

Environment Variables in Vercel:

  • VITE_CONTRACT_ADDRESS
  • VITE_RPC_URL
  • VITE_SUPABASE_URL
  • VITE_SUPABASE_ANON_KEY
  • VITE_APP_URL
  • VITE_NETWORK_NAME
  • VITE_CHAIN_ID

📊 Database Schema

The application uses Supabase PostgreSQL with the following tables:

  • shots: Records all shot attempts with discount tracking
  • winners: Tracks jackpot winners
  • sponsors: Manages sponsorship rounds
  • players: Player statistics and rankings
  • referral_codes: User referral codes for viral growth
  • referrals: Tracks referral relationships
  • referral_discounts: Manages discount rewards and usage

Real-time subscriptions provide live updates for:

  • New winners
  • Shot attempts
  • Sponsor activations

🎨 Components

Core Components

  • GameButton: Main "Take the Shot" button with loading states
  • PotDisplay: Real-time jackpot amount display
  • WalletConnect: Multi-wallet connection interface
  • WinnerAnimation: Confetti and celebration effects
  • Leaderboard: Top players and statistics
  • RecentWinners: Live winner feed
  • SponsorBanner: Sponsor branding display
  • ReferralSystem: Referral code management and sharing
  • DiscountButton: Apply referral discounts to shots
  • ReferralLeaderboard: Top referrers and statistics

Stores (State Management)

  • gameStore: Game state, contract interactions, database integration
  • walletStore: Wallet connection and Web3 functionality
  • toastStore: User notifications and feedback

🔧 Development Scripts

# Development
pnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production build# Testing
pnpm test# Run frontend tests
pnpm test:contracts # Run smart contract tests
pnpm test:all # Run all tests
pnpm coverage # Generate test coverage# Smart Contract
pnpm compile # Compile contracts
pnpm deploy:testnet # Deploy to Sepolia
pnpm verify:testnet # Verify on Etherscan# Code Quality
pnpm lint # Run ESLint
pnpm format # Format with Prettier

🚨 Security Considerations

Smart Contract Security

  • Audited Libraries: Uses OpenZeppelin's battle-tested contracts
  • Reentrancy Protection: ReentrancyGuard prevents reentrancy attacks
  • Access Control: Ownable pattern for admin functions
  • Emergency Pause: Pausable functionality for emergency stops
  • Input Validation: Proper validation of all inputs

Frontend Security

  • Environment Variables: Sensitive data stored in environment variables
  • HTTPS Only: All production traffic over HTTPS
  • Content Security Policy: Implemented via Vercel headers
  • XSS Protection: Framework-level XSS protection

📈 Performance Optimizations

  • Database Indexing: Optimized queries with proper indexes
  • Real-time Subscriptions: Efficient WebSocket connections
  • Caching: Strategic caching of contract calls
  • Code Splitting: Lazy loading of components
  • Image Optimization: Optimized assets and images

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite: pnpm test:all
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Submit a pull request

Development Guidelines

  • Follow the existing code style
  • Write tests for new features
  • Update documentation as needed
  • Use conventional commit messages

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

Important: This is a game of chance involving real cryptocurrency. Please consider the following:

  • Gambling Risk: Only gamble with funds you can afford to lose
  • Smart Contract Risk: Smart contracts may contain bugs or vulnerabilities
  • Regulatory Compliance: Ensure compliance with local gambling laws
  • No Guarantees: No guarantees of winnings or returns
  • Educational Purpose: This project is primarily for educational purposes

🆘 Support

  • Documentation: Check this README and inline code comments
  • Issues: Report bugs via GitHub Issues
  • Discussions: Join discussions in GitHub Discussions
  • Community: Follow updates on Twitter @profullstackinc
  • Discord: Join our community on Discord

🎯 Roadmap

Phase 1 (Current)

  • Core game mechanics
  • Smart contract deployment
  • Frontend application
  • Database integration
  • Real-time updates

Phase 2 (Planned)

  • Mobile app development
  • Advanced analytics dashboard
  • NFT rewards for winners
  • Referral system with discount rewards
  • Multiple game modes

Phase 3 (Future)

  • Layer 2 integration (Polygon, Arbitrum)
  • DAO governance
  • Tournament system
  • Cross-chain compatibility

Built with ❤️ by the ETH Shot team

About

A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - profullstack/ethshot-web: A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot. · GitHub
Skip to content

Latest commit

History

336 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ETH Shot 🎯

Node.jsSvelteKitEthers.jsSupabaseMocha+ChaiLicense: MITDeploy with VercelSepolia NetworkEthereum Mainnet

A viral Ethereum-powered game where users pay 0.0005 ETH per shot for a 1% chance to win the jackpot.

🎮 Game Overview

ETH Shot is a decentralized gambling game built on Ethereum where players take shots at winning the jackpot. Each shot costs 0.0005 ETH with a 1% chance of winning the entire pot. The game features real-time updates, social sharing, sponsor integration, and a viral referral system with discount rewards.

✨ Features

  • 🎯 Smart Contract Game: Built on Ethereum with provably fair 1% win probability
  • 💰 Dynamic Jackpot: Pot grows with each shot, 90% goes to winner
  • 🔒 Wallet Integration: Connect with MetaMask, WalletConnect, and other Web3 wallets
  • ⚡ Real-time Updates: Live pot updates and winner announcements via Supabase
  • ⏰ Cooldown System: 1-hour cooldown between shots per wallet address
  • 🎪 Sponsor Rounds: Businesses can sponsor rounds for 0.001 ETH with custom branding
  • 🎯 Referral System: Invite friends and earn discount rewards for viral growth
  • 💰 Discount Rewards: 20% discounts on shots earned through referrals with 30-day expiration
  • 📱 Social Sharing: Share wins and referral links on Twitter
  • 🎨 Winner Animations: Confetti and celebration effects for jackpot wins
  • 📊 Leaderboards: Track top players, recent winners, and referral champions
  • 📱 Responsive Design: Optimized for desktop and mobile devices

🛠 Tech Stack

Smart Contract

  • Solidity: Smart contract development
  • OpenZeppelin: Security libraries (ReentrancyGuard, Pausable, Ownable)
  • Hardhat: Development environment and testing

Frontend

  • SvelteKit: Modern web framework with SSR
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first CSS framework
  • Ethers.js v6: Ethereum interaction library
  • Web3Modal: Multi-wallet connection

Backend & Database

  • Supabase: PostgreSQL database with real-time subscriptions
  • Real-time subscriptions: Live updates for winners, shots, and sponsors

Testing & Quality

  • Mocha + Chai: JavaScript testing framework
  • Hardhat: Smart contract testing
  • ESLint + Prettier: Code formatting and linting
  • Sinon: Mocking and stubbing for tests

Deployment

  • Vercel: Frontend hosting and deployment
  • Sepolia Testnet: Ethereum testnet for testing

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • pnpm (recommended) or npm
  • MetaMask or other Web3 wallet
  • Infura/Alchemy API key
  • Supabase account

Installation

  1. Clone the repository:
git clone https://github.com/your-username/ethshot-web.git
cd ethshot-web
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
cp .env.example .env

Edit .env with your configuration:

# Smart Contract ConfigurationVITE_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890VITE_RPC_URL=https://sepolia.infura.io/v3/your-infura-key# Supabase ConfigurationVITE_SUPABASE_URL=https://your-project.supabase.coVITE_SUPABASE_ANON_KEY=your-anon-key# Application ConfigurationVITE_APP_URL=https://ethshot.ioVITE_NETWORK_NAME=Sepolia TestnetVITE_CHAIN_ID=11155111
  1. Start the development server:
pnpm dev
  1. Open http://localhost:5173 in your browser.

📋 Smart Contract

The game is powered by a Solidity smart contract with the following specifications:

Game Mechanics

  • Shot Cost: 0.0005 ETH per shot (0.0004 ETH with 20% referral discount)
  • Win Probability: 1% chance to win the jackpot
  • Payout Split: 90% to winner, 10% to contract owner
  • Cooldown Period: 1 hour (3600 seconds) between shots per wallet
  • Sponsor Cost: 0.001 ETH to sponsor a round with custom branding
  • Referral Discounts: 20% discount for both referrer and referee

Key Functions

  • takeShot(): Take a shot at the jackpot (payable)
  • sponsorRound(string name, string logoUrl): Sponsor a round (payable)
  • getCurrentPot(): Get current jackpot amount
  • getPlayerStats(address): Get player statistics
  • canTakeShot(address): Check if player can take a shot
  • getCooldownRemaining(address): Get remaining cooldown time

Security Features

  • ReentrancyGuard: Prevents reentrancy attacks
  • Pausable: Emergency pause functionality
  • Ownable: Access control for admin functions
  • Randomness: Uses block hash and timestamp for randomness

🧪 Testing

Run Smart Contract Tests

pnpm test:contracts

Run Frontend Tests

pnpm test

Run All Tests

pnpm test:all

Test Coverage

pnpm coverage

🚀 Deployment

1. Smart Contract Deployment

Deploy to Sepolia Testnet:

# Configure your private key in hardhat.config.js
pnpm deploy:testnet

Verify Contract on Etherscan:

pnpm verify:testnet

2. Database Setup

  1. Create a new Supabase project
  2. Run the SQL schema from supabase/schema.sql
  3. Configure Row Level Security (RLS) policies
  4. Update environment variables with Supabase credentials

3. Frontend Deployment

Deploy to Vercel:

# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod

Environment Variables in Vercel:

  • VITE_CONTRACT_ADDRESS
  • VITE_RPC_URL
  • VITE_SUPABASE_URL
  • VITE_SUPABASE_ANON_KEY
  • VITE_APP_URL
  • VITE_NETWORK_NAME
  • VITE_CHAIN_ID

📊 Database Schema

The application uses Supabase PostgreSQL with the following tables:

  • shots: Records all shot attempts with discount tracking
  • winners: Tracks jackpot winners
  • sponsors: Manages sponsorship rounds
  • players: Player statistics and rankings
  • referral_codes: User referral codes for viral growth
  • referrals: Tracks referral relationships
  • referral_discounts: Manages discount rewards and usage

Real-time subscriptions provide live updates for:

  • New winners
  • Shot attempts
  • Sponsor activations

🎨 Components

Core Components

  • GameButton: Main "Take the Shot" button with loading states
  • PotDisplay: Real-time jackpot amount display
  • WalletConnect: Multi-wallet connection interface
  • WinnerAnimation: Confetti and celebration effects
  • Leaderboard: Top players and statistics
  • RecentWinners: Live winner feed
  • SponsorBanner: Sponsor branding display
  • ReferralSystem: Referral code management and sharing
  • DiscountButton: Apply referral discounts to shots
  • ReferralLeaderboard: Top referrers and statistics

Stores (State Management)

  • gameStore: Game state, contract interactions, database integration
  • walletStore: Wallet connection and Web3 functionality
  • toastStore: User notifications and feedback

🔧 Development Scripts

# Development
pnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production build# Testing
pnpm test# Run frontend tests
pnpm test:contracts # Run smart contract tests
pnpm test:all # Run all tests
pnpm coverage # Generate test coverage# Smart Contract
pnpm compile # Compile contracts
pnpm deploy:testnet # Deploy to Sepolia
pnpm verify:testnet # Verify on Etherscan# Code Quality
pnpm lint # Run ESLint
pnpm format # Format with Prettier

🚨 Security Considerations

Smart Contract Security

  • Audited Libraries: Uses OpenZeppelin's battle-tested contracts
  • Reentrancy Protection: ReentrancyGuard prevents reentrancy attacks
  • Access Control: Ownable pattern for admin functions
  • Emergency Pause: Pausable functionality for emergency stops
  • Input Validation: Proper validation of all inputs

Frontend Security

  • Environment Variables: Sensitive data stored in environment variables
  • HTTPS Only: All production traffic over HTTPS
  • Content Security Policy: Implemented via Vercel headers
  • XSS Protection: Framework-level XSS protection

📈 Performance Optimizations

  • Database Indexing: Optimized queries with proper indexes
  • Real-time Subscriptions: Efficient WebSocket connections
  • Caching: Strategic caching of contract calls
  • Code Splitting: Lazy loading of components
  • Image Optimization: Optimized assets and images

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite: pnpm test:all
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Submit a pull request

Development Guidelines

  • Follow the existing code style
  • Write tests for new features
  • Update documentation as needed
  • Use conventional commit messages

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

Important: This is a game of chance involving real cryptocurrency. Please consider the following:

  • Gambling Risk: Only gamble with funds you can afford to lose
  • Smart Contract Risk: Smart contracts may contain bugs or vulnerabilities
  • Regulatory Compliance: Ensure compliance with local gambling laws
  • No Guarantees: No guarantees of winnings or returns
  • Educational Purpose: This project is primarily for educational purposes

🆘 Support

  • Documentation: Check this README and inline code comments
  • Issues: Report bugs via GitHub Issues
  • Discussions: Join discussions in GitHub Discussions
  • Community: Follow updates on Twitter @profullstackinc
  • Discord: Join our community on Discord

🎯 Roadmap

Phase 1 (Current)

  • Core game mechanics
  • Smart contract deployment
  • Frontend application
  • Database integration
  • Real-time updates

Phase 2 (Planned)

  • Mobile app development
  • Advanced analytics dashboard
  • NFT rewards for winners
  • Referral system with discount rewards
  • Multiple game modes

Phase 3 (Future)

  • Layer 2 integration (Polygon, Arbitrum)
  • DAO governance
  • Tournament system
  • Cross-chain compatibility

Built with ❤️ by the ETH Shot team

About

A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - profullstack/ethshot-web: A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot. · GitHub
Skip to content

Latest commit

History

336 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ETH Shot 🎯

Node.jsSvelteKitEthers.jsSupabaseMocha+ChaiLicense: MITDeploy with VercelSepolia NetworkEthereum Mainnet

A viral Ethereum-powered game where users pay 0.0005 ETH per shot for a 1% chance to win the jackpot.

🎮 Game Overview

ETH Shot is a decentralized gambling game built on Ethereum where players take shots at winning the jackpot. Each shot costs 0.0005 ETH with a 1% chance of winning the entire pot. The game features real-time updates, social sharing, sponsor integration, and a viral referral system with discount rewards.

✨ Features

  • 🎯 Smart Contract Game: Built on Ethereum with provably fair 1% win probability
  • 💰 Dynamic Jackpot: Pot grows with each shot, 90% goes to winner
  • 🔒 Wallet Integration: Connect with MetaMask, WalletConnect, and other Web3 wallets
  • ⚡ Real-time Updates: Live pot updates and winner announcements via Supabase
  • ⏰ Cooldown System: 1-hour cooldown between shots per wallet address
  • 🎪 Sponsor Rounds: Businesses can sponsor rounds for 0.001 ETH with custom branding
  • 🎯 Referral System: Invite friends and earn discount rewards for viral growth
  • 💰 Discount Rewards: 20% discounts on shots earned through referrals with 30-day expiration
  • 📱 Social Sharing: Share wins and referral links on Twitter
  • 🎨 Winner Animations: Confetti and celebration effects for jackpot wins
  • 📊 Leaderboards: Track top players, recent winners, and referral champions
  • 📱 Responsive Design: Optimized for desktop and mobile devices

🛠 Tech Stack

Smart Contract

  • Solidity: Smart contract development
  • OpenZeppelin: Security libraries (ReentrancyGuard, Pausable, Ownable)
  • Hardhat: Development environment and testing

Frontend

  • SvelteKit: Modern web framework with SSR
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first CSS framework
  • Ethers.js v6: Ethereum interaction library
  • Web3Modal: Multi-wallet connection

Backend & Database

  • Supabase: PostgreSQL database with real-time subscriptions
  • Real-time subscriptions: Live updates for winners, shots, and sponsors

Testing & Quality

  • Mocha + Chai: JavaScript testing framework
  • Hardhat: Smart contract testing
  • ESLint + Prettier: Code formatting and linting
  • Sinon: Mocking and stubbing for tests

Deployment

  • Vercel: Frontend hosting and deployment
  • Sepolia Testnet: Ethereum testnet for testing

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • pnpm (recommended) or npm
  • MetaMask or other Web3 wallet
  • Infura/Alchemy API key
  • Supabase account

Installation

  1. Clone the repository:
git clone https://github.com/your-username/ethshot-web.git
cd ethshot-web
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
cp .env.example .env

Edit .env with your configuration:

# Smart Contract ConfigurationVITE_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890VITE_RPC_URL=https://sepolia.infura.io/v3/your-infura-key# Supabase ConfigurationVITE_SUPABASE_URL=https://your-project.supabase.coVITE_SUPABASE_ANON_KEY=your-anon-key# Application ConfigurationVITE_APP_URL=https://ethshot.ioVITE_NETWORK_NAME=Sepolia TestnetVITE_CHAIN_ID=11155111
  1. Start the development server:
pnpm dev
  1. Open http://localhost:5173 in your browser.

📋 Smart Contract

The game is powered by a Solidity smart contract with the following specifications:

Game Mechanics

  • Shot Cost: 0.0005 ETH per shot (0.0004 ETH with 20% referral discount)
  • Win Probability: 1% chance to win the jackpot
  • Payout Split: 90% to winner, 10% to contract owner
  • Cooldown Period: 1 hour (3600 seconds) between shots per wallet
  • Sponsor Cost: 0.001 ETH to sponsor a round with custom branding
  • Referral Discounts: 20% discount for both referrer and referee

Key Functions

  • takeShot(): Take a shot at the jackpot (payable)
  • sponsorRound(string name, string logoUrl): Sponsor a round (payable)
  • getCurrentPot(): Get current jackpot amount
  • getPlayerStats(address): Get player statistics
  • canTakeShot(address): Check if player can take a shot
  • getCooldownRemaining(address): Get remaining cooldown time

Security Features

  • ReentrancyGuard: Prevents reentrancy attacks
  • Pausable: Emergency pause functionality
  • Ownable: Access control for admin functions
  • Randomness: Uses block hash and timestamp for randomness

🧪 Testing

Run Smart Contract Tests

pnpm test:contracts

Run Frontend Tests

pnpm test

Run All Tests

pnpm test:all

Test Coverage

pnpm coverage

🚀 Deployment

1. Smart Contract Deployment

Deploy to Sepolia Testnet:

# Configure your private key in hardhat.config.js
pnpm deploy:testnet

Verify Contract on Etherscan:

pnpm verify:testnet

2. Database Setup

  1. Create a new Supabase project
  2. Run the SQL schema from supabase/schema.sql
  3. Configure Row Level Security (RLS) policies
  4. Update environment variables with Supabase credentials

3. Frontend Deployment

Deploy to Vercel:

# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod

Environment Variables in Vercel:

  • VITE_CONTRACT_ADDRESS
  • VITE_RPC_URL
  • VITE_SUPABASE_URL
  • VITE_SUPABASE_ANON_KEY
  • VITE_APP_URL
  • VITE_NETWORK_NAME
  • VITE_CHAIN_ID

📊 Database Schema

The application uses Supabase PostgreSQL with the following tables:

  • shots: Records all shot attempts with discount tracking
  • winners: Tracks jackpot winners
  • sponsors: Manages sponsorship rounds
  • players: Player statistics and rankings
  • referral_codes: User referral codes for viral growth
  • referrals: Tracks referral relationships
  • referral_discounts: Manages discount rewards and usage

Real-time subscriptions provide live updates for:

  • New winners
  • Shot attempts
  • Sponsor activations

🎨 Components

Core Components

  • GameButton: Main "Take the Shot" button with loading states
  • PotDisplay: Real-time jackpot amount display
  • WalletConnect: Multi-wallet connection interface
  • WinnerAnimation: Confetti and celebration effects
  • Leaderboard: Top players and statistics
  • RecentWinners: Live winner feed
  • SponsorBanner: Sponsor branding display
  • ReferralSystem: Referral code management and sharing
  • DiscountButton: Apply referral discounts to shots
  • ReferralLeaderboard: Top referrers and statistics

Stores (State Management)

  • gameStore: Game state, contract interactions, database integration
  • walletStore: Wallet connection and Web3 functionality
  • toastStore: User notifications and feedback

🔧 Development Scripts

# Development
pnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production build# Testing
pnpm test# Run frontend tests
pnpm test:contracts # Run smart contract tests
pnpm test:all # Run all tests
pnpm coverage # Generate test coverage# Smart Contract
pnpm compile # Compile contracts
pnpm deploy:testnet # Deploy to Sepolia
pnpm verify:testnet # Verify on Etherscan# Code Quality
pnpm lint # Run ESLint
pnpm format # Format with Prettier

🚨 Security Considerations

Smart Contract Security

  • Audited Libraries: Uses OpenZeppelin's battle-tested contracts
  • Reentrancy Protection: ReentrancyGuard prevents reentrancy attacks
  • Access Control: Ownable pattern for admin functions
  • Emergency Pause: Pausable functionality for emergency stops
  • Input Validation: Proper validation of all inputs

Frontend Security

  • Environment Variables: Sensitive data stored in environment variables
  • HTTPS Only: All production traffic over HTTPS
  • Content Security Policy: Implemented via Vercel headers
  • XSS Protection: Framework-level XSS protection

📈 Performance Optimizations

  • Database Indexing: Optimized queries with proper indexes
  • Real-time Subscriptions: Efficient WebSocket connections
  • Caching: Strategic caching of contract calls
  • Code Splitting: Lazy loading of components
  • Image Optimization: Optimized assets and images

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite: pnpm test:all
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Submit a pull request

Development Guidelines

  • Follow the existing code style
  • Write tests for new features
  • Update documentation as needed
  • Use conventional commit messages

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

Important: This is a game of chance involving real cryptocurrency. Please consider the following:

  • Gambling Risk: Only gamble with funds you can afford to lose
  • Smart Contract Risk: Smart contracts may contain bugs or vulnerabilities
  • Regulatory Compliance: Ensure compliance with local gambling laws
  • No Guarantees: No guarantees of winnings or returns
  • Educational Purpose: This project is primarily for educational purposes

🆘 Support

  • Documentation: Check this README and inline code comments
  • Issues: Report bugs via GitHub Issues
  • Discussions: Join discussions in GitHub Discussions
  • Community: Follow updates on Twitter @profullstackinc
  • Discord: Join our community on Discord

🎯 Roadmap

Phase 1 (Current)

  • Core game mechanics
  • Smart contract deployment
  • Frontend application
  • Database integration
  • Real-time updates

Phase 2 (Planned)

  • Mobile app development
  • Advanced analytics dashboard
  • NFT rewards for winners
  • Referral system with discount rewards
  • Multiple game modes

Phase 3 (Future)

  • Layer 2 integration (Polygon, Arbitrum)
  • DAO governance
  • Tournament system
  • Cross-chain compatibility

Built with ❤️ by the ETH Shot team

About

A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - profullstack/ethshot-web: A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot. · GitHub
Skip to content

Latest commit

History

336 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

ETH Shot 🎯

Node.jsSvelteKitEthers.jsSupabaseMocha+ChaiLicense: MITDeploy with VercelSepolia NetworkEthereum Mainnet

A viral Ethereum-powered game where users pay 0.0005 ETH per shot for a 1% chance to win the jackpot.

🎮 Game Overview

ETH Shot is a decentralized gambling game built on Ethereum where players take shots at winning the jackpot. Each shot costs 0.0005 ETH with a 1% chance of winning the entire pot. The game features real-time updates, social sharing, sponsor integration, and a viral referral system with discount rewards.

✨ Features

  • 🎯 Smart Contract Game: Built on Ethereum with provably fair 1% win probability
  • 💰 Dynamic Jackpot: Pot grows with each shot, 90% goes to winner
  • 🔒 Wallet Integration: Connect with MetaMask, WalletConnect, and other Web3 wallets
  • ⚡ Real-time Updates: Live pot updates and winner announcements via Supabase
  • ⏰ Cooldown System: 1-hour cooldown between shots per wallet address
  • 🎪 Sponsor Rounds: Businesses can sponsor rounds for 0.001 ETH with custom branding
  • 🎯 Referral System: Invite friends and earn discount rewards for viral growth
  • 💰 Discount Rewards: 20% discounts on shots earned through referrals with 30-day expiration
  • 📱 Social Sharing: Share wins and referral links on Twitter
  • 🎨 Winner Animations: Confetti and celebration effects for jackpot wins
  • 📊 Leaderboards: Track top players, recent winners, and referral champions
  • 📱 Responsive Design: Optimized for desktop and mobile devices

🛠 Tech Stack

Smart Contract

  • Solidity: Smart contract development
  • OpenZeppelin: Security libraries (ReentrancyGuard, Pausable, Ownable)
  • Hardhat: Development environment and testing

Frontend

  • SvelteKit: Modern web framework with SSR
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first CSS framework
  • Ethers.js v6: Ethereum interaction library
  • Web3Modal: Multi-wallet connection

Backend & Database

  • Supabase: PostgreSQL database with real-time subscriptions
  • Real-time subscriptions: Live updates for winners, shots, and sponsors

Testing & Quality

  • Mocha + Chai: JavaScript testing framework
  • Hardhat: Smart contract testing
  • ESLint + Prettier: Code formatting and linting
  • Sinon: Mocking and stubbing for tests

Deployment

  • Vercel: Frontend hosting and deployment
  • Sepolia Testnet: Ethereum testnet for testing

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • pnpm (recommended) or npm
  • MetaMask or other Web3 wallet
  • Infura/Alchemy API key
  • Supabase account

Installation

  1. Clone the repository:
git clone https://github.com/your-username/ethshot-web.git
cd ethshot-web
  1. Install dependencies:
pnpm install
  1. Set up environment variables:
cp .env.example .env

Edit .env with your configuration:

# Smart Contract ConfigurationVITE_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890VITE_RPC_URL=https://sepolia.infura.io/v3/your-infura-key# Supabase ConfigurationVITE_SUPABASE_URL=https://your-project.supabase.coVITE_SUPABASE_ANON_KEY=your-anon-key# Application ConfigurationVITE_APP_URL=https://ethshot.ioVITE_NETWORK_NAME=Sepolia TestnetVITE_CHAIN_ID=11155111
  1. Start the development server:
pnpm dev
  1. Open http://localhost:5173 in your browser.

📋 Smart Contract

The game is powered by a Solidity smart contract with the following specifications:

Game Mechanics

  • Shot Cost: 0.0005 ETH per shot (0.0004 ETH with 20% referral discount)
  • Win Probability: 1% chance to win the jackpot
  • Payout Split: 90% to winner, 10% to contract owner
  • Cooldown Period: 1 hour (3600 seconds) between shots per wallet
  • Sponsor Cost: 0.001 ETH to sponsor a round with custom branding
  • Referral Discounts: 20% discount for both referrer and referee

Key Functions

  • takeShot(): Take a shot at the jackpot (payable)
  • sponsorRound(string name, string logoUrl): Sponsor a round (payable)
  • getCurrentPot(): Get current jackpot amount
  • getPlayerStats(address): Get player statistics
  • canTakeShot(address): Check if player can take a shot
  • getCooldownRemaining(address): Get remaining cooldown time

Security Features

  • ReentrancyGuard: Prevents reentrancy attacks
  • Pausable: Emergency pause functionality
  • Ownable: Access control for admin functions
  • Randomness: Uses block hash and timestamp for randomness

🧪 Testing

Run Smart Contract Tests

pnpm test:contracts

Run Frontend Tests

pnpm test

Run All Tests

pnpm test:all

Test Coverage

pnpm coverage

🚀 Deployment

1. Smart Contract Deployment

Deploy to Sepolia Testnet:

# Configure your private key in hardhat.config.js
pnpm deploy:testnet

Verify Contract on Etherscan:

pnpm verify:testnet

2. Database Setup

  1. Create a new Supabase project
  2. Run the SQL schema from supabase/schema.sql
  3. Configure Row Level Security (RLS) policies
  4. Update environment variables with Supabase credentials

3. Frontend Deployment

Deploy to Vercel:

# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod

Environment Variables in Vercel:

  • VITE_CONTRACT_ADDRESS
  • VITE_RPC_URL
  • VITE_SUPABASE_URL
  • VITE_SUPABASE_ANON_KEY
  • VITE_APP_URL
  • VITE_NETWORK_NAME
  • VITE_CHAIN_ID

📊 Database Schema

The application uses Supabase PostgreSQL with the following tables:

  • shots: Records all shot attempts with discount tracking
  • winners: Tracks jackpot winners
  • sponsors: Manages sponsorship rounds
  • players: Player statistics and rankings
  • referral_codes: User referral codes for viral growth
  • referrals: Tracks referral relationships
  • referral_discounts: Manages discount rewards and usage

Real-time subscriptions provide live updates for:

  • New winners
  • Shot attempts
  • Sponsor activations

🎨 Components

Core Components

  • GameButton: Main "Take the Shot" button with loading states
  • PotDisplay: Real-time jackpot amount display
  • WalletConnect: Multi-wallet connection interface
  • WinnerAnimation: Confetti and celebration effects
  • Leaderboard: Top players and statistics
  • RecentWinners: Live winner feed
  • SponsorBanner: Sponsor branding display
  • ReferralSystem: Referral code management and sharing
  • DiscountButton: Apply referral discounts to shots
  • ReferralLeaderboard: Top referrers and statistics

Stores (State Management)

  • gameStore: Game state, contract interactions, database integration
  • walletStore: Wallet connection and Web3 functionality
  • toastStore: User notifications and feedback

🔧 Development Scripts

# Development
pnpm dev # Start dev server
pnpm build # Build for production
pnpm preview # Preview production build# Testing
pnpm test# Run frontend tests
pnpm test:contracts # Run smart contract tests
pnpm test:all # Run all tests
pnpm coverage # Generate test coverage# Smart Contract
pnpm compile # Compile contracts
pnpm deploy:testnet # Deploy to Sepolia
pnpm verify:testnet # Verify on Etherscan# Code Quality
pnpm lint # Run ESLint
pnpm format # Format with Prettier

🚨 Security Considerations

Smart Contract Security

  • Audited Libraries: Uses OpenZeppelin's battle-tested contracts
  • Reentrancy Protection: ReentrancyGuard prevents reentrancy attacks
  • Access Control: Ownable pattern for admin functions
  • Emergency Pause: Pausable functionality for emergency stops
  • Input Validation: Proper validation of all inputs

Frontend Security

  • Environment Variables: Sensitive data stored in environment variables
  • HTTPS Only: All production traffic over HTTPS
  • Content Security Policy: Implemented via Vercel headers
  • XSS Protection: Framework-level XSS protection

📈 Performance Optimizations

  • Database Indexing: Optimized queries with proper indexes
  • Real-time Subscriptions: Efficient WebSocket connections
  • Caching: Strategic caching of contract calls
  • Code Splitting: Lazy loading of components
  • Image Optimization: Optimized assets and images

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite: pnpm test:all
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Submit a pull request

Development Guidelines

  • Follow the existing code style
  • Write tests for new features
  • Update documentation as needed
  • Use conventional commit messages

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

Important: This is a game of chance involving real cryptocurrency. Please consider the following:

  • Gambling Risk: Only gamble with funds you can afford to lose
  • Smart Contract Risk: Smart contracts may contain bugs or vulnerabilities
  • Regulatory Compliance: Ensure compliance with local gambling laws
  • No Guarantees: No guarantees of winnings or returns
  • Educational Purpose: This project is primarily for educational purposes

🆘 Support

  • Documentation: Check this README and inline code comments
  • Issues: Report bugs via GitHub Issues
  • Discussions: Join discussions in GitHub Discussions
  • Community: Follow updates on Twitter @profullstackinc
  • Discord: Join our community on Discord

🎯 Roadmap

Phase 1 (Current)

  • Core game mechanics
  • Smart contract deployment
  • Frontend application
  • Database integration
  • Real-time updates

Phase 2 (Planned)

  • Mobile app development
  • Advanced analytics dashboard
  • NFT rewards for winners
  • Referral system with discount rewards
  • Multiple game modes

Phase 3 (Future)

  • Layer 2 integration (Polygon, Arbitrum)
  • DAO governance
  • Tournament system
  • Cross-chain compatibility

Built with ❤️ by the ETH Shot team

About

A viral Ethereum-powered game where users pay 0.001 ETH per shot for a 1% chance to win the jackpot.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages