A decentralized, transparent, and immutable tournament management system built on the Internet Computer.
At Cosmicrafts, we believe in the power of decentralization to revolutionize internet services. This open-source tournament system leverages blockchain technology to create a transparent, fair, and tamper-proof platform for competitive gaming and esports.
- 🔒 Transparency: All tournament data is stored on-chain, ensuring complete transparency
- ⚡ Immutability: Match results cannot be altered once verified
- 🎯 Fair Competition: Automated bracket generation with randomized seeding
- 🌍 Global Access: Accessible from anywhere with multi-wallet authentication
- 🔐 Secure: Leverages Internet Computer's blockchain security
- Create & Join Tournaments: Easy tournament creation with configurable parameters
- Automated Bracket Generation: Single-elimination brackets with proper seeding and bye handling
- Match Scheduling: Automatic match organization with next-match tracking
- Result Submission: Players can submit match results directly
- Admin Verification: Admin controls for verifying and managing match outcomes
- Dispute System: Built-in dispute resolution mechanism
- Internet Identity: Native ICP authentication
- NFID: Social login for Web3
- MetaMask: Ethereum wallet integration
- Phantom: Solana wallet support
- Google OAuth: Traditional social login
- Other Options: Extensible auth system via Auth0
- Real-time Tournament View: Live bracket visualization
- User Dashboard: Personal tournament history and stats
- Modern UI/UX: Beautiful, responsive design
- Multi-device Support: Works on desktop, tablet, and mobile
- Prerequisites
- Tech Stack
- Project Structure
- Getting Started
- Backend API
- Authentication
- Automation Scripts
- Deployment
- Contributing
- Resources
- License
Before you begin, ensure you have the following installed:
- DFINITY SDK (dfx) - Version 0.15.0 or higher
sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)" - Node.js - Version 16.0.0 or higher
- npm - Version 7.0.0 or higher
- Bash shell - For running automation scripts
- Perl - For script output parsing (usually pre-installed on Unix systems)
- Git - For version control
- MetaMask - Browser extension for Ethereum wallet auth
- Phantom - Browser extension for Solana wallet auth
- Motoko: Smart contract language for Internet Computer
- Internet Computer: Blockchain platform
- Candid: Interface description language
- Vue.js 3: Progressive JavaScript framework
- TypeScript: Type-safe development
- Pinia: State management
- Vue Router: Client-side routing
- Vite: Build tool and dev server
- SCSS: Styling
- @dfinity/agent: ICP agent for canister communication
- @dfinity/auth-client: Authentication library
- @dfinity/identity: Identity management
- @solana/web3.js: Solana integration
- TweetNaCl: Cryptographic operations
tournament-poll/
├── src/
│ ├── tournament_backend/ # Motoko backend canister
│ │ └── main.mo # Core tournament logic
│ ├── tournament_frontend/ # Vue.js frontend
│ │ ├── src/
│ │ │ ├── components/ # Reusable Vue components
│ │ │ │ ├── Match.vue
│ │ │ │ └── UserInfo.vue
│ │ │ ├── views/ # Page components
│ │ │ │ ├── HomeView.vue
│ │ │ │ ├── LoginView.vue
│ │ │ │ ├── DashboardView.vue
│ │ │ │ └── TournamentView.vue
│ │ │ ├── store/ # Pinia state management
│ │ │ │ ├── auth.ts # Authentication store
│ │ │ │ └── index.ts
│ │ │ ├── services/ # External services
│ │ │ │ ├── MetaMaskService.ts
│ │ │ │ └── PhantomService.ts
│ │ │ ├── router/ # Vue Router config
│ │ │ │ └── index.ts
│ │ │ ├── assets/ # Images and static files
│ │ │ └── main.js # App entry point
│ │ ├── public/ # Public assets
│ │ ├── package.json
│ │ ├── tsconfig.json
│ │ └── vite.config.js
│ └── declarations/ # Auto-generated Candid bindings
├── register_identities.sh # Identity registration script
├── tournament_script.sh # Full tournament automation
├── create_tournament.sh # Bracket creation script
├── dfx.json # DFX configuration
├── package.json # Root package config
└── README.md
-
Clone the repository
git clone https://github.com/your-username/tournament-poll.git cd tournament-poll -
Install dependencies
npm install
-
Start the Internet Computer local replica
dfx start --clean --background
-
Deploy the canisters
dfx deploy
-
Start the frontend development server
cd src/tournament_frontend npm start -
Access the application
- Frontend:
http://localhost:3000 - Backend Candid UI:
http://localhost:4943?canisterId={canister_id}
- Frontend:
For a complete local setup:
# Start the local replica
dfx start --background
# Deploy all canisters
dfx deploy
# The frontend will be available at the URL shown in the deploy outputTo get the canister ID for the frontend:
dfx canister id tournament_frontendcreateTournament
createTournament(name: Text, startDate: Time, prizePool: Text, expirationDate: Time) : async NatCreates a new tournament. Returns tournament ID. (Admin only)
joinTournament
joinTournament(tournamentId: Nat) : async BoolJoin an active tournament. Returns success status.
updateBracket
updateBracket(tournamentId: Nat) : async BoolGenerate tournament bracket with randomized seeding and bye handling.
getActiveTournaments
getActiveTournaments() : async [Tournament]Query all active tournaments accepting registrations.
getAllTournaments
getAllTournaments() : async [Tournament]Query all tournaments (active and inactive).
getTournamentBracket
getTournamentBracket(tournamentId: Nat) : async {matches: [Match]}Get the complete bracket for a tournament.
submitMatchResult
submitMatchResult(tournamentId: Nat, matchId: Nat, score: Text) : async BoolSubmit match results (participant only). Sets status to "pending verification".
adminUpdateMatch
adminUpdateMatch(tournamentId: Nat, matchId: Nat, winnerIndex: Nat, score: Text) : async BoolVerify and update match results (admin only). Auto-advances winner in bracket.
disputeMatch
disputeMatch(tournamentId: Nat, matchId: Nat, reason: Text) : async BoolFile a dispute for a match result.
submitFeedback
submitFeedback(tournamentId: Nat, feedbackText: Text) : async BoolSubmit feedback for a tournament.
type Tournament = {
id: Nat;
name: Text;
startDate: Time.Time;
prizePool: Text;
expirationDate: Time.Time;
participants: [Principal];
registeredParticipants: [Principal];
isActive: Bool;
bracketCreated: Bool;
matchCounter: Nat;
};
type Match = {
id: Nat;
tournamentId: Nat;
participants: [Principal];
result: ?{winner: Principal; score: Text};
status: Text; // "scheduled", "pending verification", "verified"
nextMatchId: ?Nat;
};The system supports multiple authentication methods through a unified authentication store:
-
Internet Identity - Native ICP authentication
- Decentralized identity management
- No password required
- Privacy-preserving
-
NFID - Social login for Web3
- Email-based Web3 identity
- User-friendly onboarding
-
MetaMask - Ethereum wallet
- Sign message to generate ICP identity
- Deterministic key generation from signature
-
Phantom - Solana wallet
- Sign message to generate ICP identity
- Cross-chain compatibility
-
Google OAuth - Traditional social login
- Familiar login flow
- Keys generated from Google Sub ID
All authentication methods generate an Ed25519 key pair that's used to create an ICP identity:
- User authenticates with their chosen method
- A unique signature/identifier is obtained
- SHA-256 hash of the signature creates a deterministic seed
- Ed25519 key pair is generated from the seed
- ICP identity is created and used for all backend interactions
Quickly create multiple test identities for development and testing.
./register_identities.shPrompts:
- Number of identities to create
Output:
- Creates identities named
player1,player2, etc. - Lists all created principals
Complete tournament lifecycle automation: create, register players, generate bracket, and simulate matches.
./tournament_script.shFeatures:
- Creates a tournament
- Registers players
- Generates bracket
- Simulates match results
- Verifies matches
- Displays final bracket
Creates a tournament and generates the initial bracket only.
./create_tournament.shUse case: When you want to manually manage match results.
-
Set up cycles wallet (if not already done)
dfx identity get-wallet
-
Deploy to mainnet
dfx deploy --network ic
-
Get canister IDs
dfx canister id tournament_backend --network ic dfx canister id tournament_frontend --network ic
Create a .env file in src/tournament_frontend/:
VITE_NETWORK=ic # or "local"
VITE_GOOGLE_CLIENT_ID=your_id_here
VITE_AUTH0_REDIRECT_URI=your_uri_herenpm run buildThis creates optimized production builds in src/tournament_frontend/dist/.
We welcome contributions from the community! Here's how you can help:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m 'Add amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
- Follow existing code style
- Add tests for new features
- Update documentation as needed
- Keep commits atomic and well-described
This project is open source and available for developers worldwide to build upon and create their own decentralized tournaments, contests, and hackathons.
Built with ❤️ by Cosmicrafts
Empowering the future of decentralized gaming