Skip to content
harsh-a-pariharPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

πŸ† AlgoHack - Blockchain Prize Distribution Platform

License: MIT Algorand TypeScript React

Revolutionizing hackathon prize distribution with blockchain technology. 99% cost reduction and instant processing for platforms like Devfolio, MLH, and more.

πŸ“‹ Table of Contents

🎯 Overview

AlgoHack is a comprehensive blockchain-based prize distribution platform designed specifically for hackathon organizers and participants. Built on the Algorand blockchain, it provides instant, secure, and cost-effective prize distribution solutions that eliminate traditional banking delays and high transaction fees.

πŸš€ Problem Solved

  • Traditional Methods: $2,500+ cost, weeks to process
  • AlgoHack Solution: $12 cost, instant processing
  • Result: 99% cost reduction with immediate payouts

✨ Key Features

🏒 For Hackathon Organizers & Platforms

  • Instant Prize Distribution: Deploy smart contracts and distribute prizes in real-time
  • Multi-Platform Integration: Seamless integration with Devfolio, MLH, and other platforms
  • White-label Solutions: Customizable branding for different platforms
  • API-First Architecture: Easy integration with existing systems
  • Smart Contract Escrow: Secure and transparent prize management
  • Batch Processing: Handle multiple winners efficiently

πŸ† For Participants

  • Instant Prize Claims: No waiting weeks for processing
  • Transparent Transactions: All transactions visible on blockchain
  • Global Accessibility: Works worldwide with instant transfers
  • Secure Blockchain: Military-grade security protection
  • No Waiting Periods: Immediate access to winnings

πŸ”§ Technical Features

  • Multi-Wallet Support: Connect with Pera, Defly, and other Algorand wallets
  • Real-time Verification: Live transaction verification and status updates
  • Responsive Design: Modern, professional UI that works on all devices
  • Type Safety: Full TypeScript implementation for reliability
  • Comprehensive Testing: Unit tests, integration tests, and E2E testing

πŸ—οΈ Architecture

The platform consists of three main layers:

  1. Frontend Layer: React-based user interface with wallet integration
  2. Smart Contract Layer: 8 core smart contracts handling different aspects
  3. Blockchain Layer: Algorand testnet and mainnet integration

πŸ› οΈ Tech Stack

Frontend

  • React 18 - Modern UI library
  • TypeScript - Type-safe development
  • Tailwind CSS - Utility-first CSS framework
  • DaisyUI - Component library
  • Vite - Fast build tool
  • @txnlab/use-wallet - Algorand wallet integration

Smart Contracts

  • AlgoKit - Algorand development framework
  • Puya - TypeScript smart contract language
  • Algorand TypeScript SDK - Blockchain interaction

Development Tools

  • ESLint - Code linting
  • Prettier - Code formatting
  • Jest - Unit testing
  • Playwright - E2E testing
  • Vitest - Fast testing framework

πŸ“ Project Structure

algohack/
β”œβ”€β”€ projects/
β”‚   β”œβ”€β”€ algohack-frontend/          # React frontend application
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ components/         # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ contracts/          # Generated smart contract clients
β”‚   β”‚   β”‚   β”œβ”€β”€ contexts/           # React contexts
β”‚   β”‚   β”‚   β”œβ”€β”€ utils/              # Utility functions
β”‚   β”‚   β”‚   └── styles/             # CSS styles
β”‚   β”‚   β”œβ”€β”€ public/                 # Static assets
β”‚   β”‚   └── tests/                  # Test files
β”‚   β”‚
β”‚   β”œβ”€β”€ algohack-contracts/         # Smart contracts
β”‚   β”‚   └── smart_contracts/
β”‚   β”‚       β”œβ”€β”€ simple_prize_distribution/
β”‚   β”‚       β”œβ”€β”€ batch_distribution/
β”‚   β”‚       β”œβ”€β”€ compliance_oracle/
β”‚   β”‚       β”œβ”€β”€ emergency_recovery/
β”‚   β”‚       β”œβ”€β”€ multisig_wallet/
β”‚   β”‚       β”œβ”€β”€ platform_fee_manager/
β”‚   β”‚       β”œβ”€β”€ reputation_system/
β”‚   β”‚       └── tax_compliance/
β”‚   β”‚
β”‚   └── algohack-api/               # Backend API (if applicable)
β”‚
β”œβ”€β”€ .github/workflows/              # CI/CD workflows
β”œβ”€β”€ docs/                          # Documentation
└── README.md                      # This file

πŸš€ Getting Started

Prerequisites

  • Node.js >= 20.0
  • npm >= 9.0
  • Docker (for local development)
  • AlgoKit CLI (install from here)

Installation

  1. Clone the repository

    git clone https://github.com/harsh-a-parihar/AlgoHack.git
    cd AlgoHack
  2. Bootstrap the project

    algokit project bootstrap all
  3. Generate environment files

    cd projects/algohack-contracts
    algokit generate env-file -a target_network localnet
  4. Build the project

    algokit project run build

Development

  1. Start the frontend development server

    cd projects/algohack-frontend
    npm run dev
  2. Deploy smart contracts to localnet

    cd projects/algohack-contracts
    npm run deploy
  3. Run tests

    # Frontend tests
    cd projects/algohack-frontend
    npm test
    
    # Smart contract tests
    cd projects/algohack-contracts
    npm test

πŸ”— Smart Contracts

Core Contracts

1. Simple Prize Distribution

  • Purpose: Basic prize distribution functionality
  • Features: Create distributions, fund contracts, claim prizes
  • File: simple_prize_distribution/contract.algo.ts

2. Batch Distribution

  • Purpose: Handle multiple prize distributions efficiently
  • Features: Batch processing, gas optimization
  • File: batch_distribution/contract.algo.ts

3. Compliance Oracle

  • Purpose: Ensure regulatory compliance
  • Features: KYC verification, AML checks
  • File: compliance_oracle/contract.algo.ts

4. Emergency Recovery

  • Purpose: Emergency fund recovery mechanisms
  • Features: Multi-sig recovery, time-locked recovery
  • File: emergency_recovery/contract.algo.ts

5. Multi-Sig Wallet

  • Purpose: Secure fund management
  • Features: Multi-signature transactions, threshold management
  • File: multisig_wallet/contract.algo.ts

6. Platform Fee Manager

  • Purpose: Handle platform fees and revenue sharing
  • Features: Fee calculation, automatic distribution
  • File: platform_fee_manager/contract.algo.ts

7. Reputation System

  • Purpose: Track organizer and participant reputation
  • Features: Reputation scoring, trust metrics
  • File: reputation_system/contract.algo.ts

8. Tax Compliance

  • Purpose: Handle tax reporting and compliance
  • Features: Tax calculation, reporting generation
  • File: tax_compliance/contract.algo.ts

Contract Deployment

# Deploy to localnet
cd projects/algohack-contracts
npm run deploy

# Deploy to testnet
algokit deploy --target-network testnet

# Deploy to mainnet
algokit deploy --target-network mainnet

🎨 Frontend Application

Key Components

1. Home Page (Home.tsx)

  • Hero Section: Main landing page with statistics
  • Feature Cards: Role-based access (Organizer, Winner, Platform)
  • Demo Section: Interactive demonstrations
  • Professional UI: Modern, responsive design

2. Prize Distribution (PrizeDistribution.tsx)

  • Create Distribution: Set up new prize distributions
  • Fund Contract: Add funds to distribution contracts
  • Manage Events: Handle event details and winners

3. Winner Claiming (WinnerClaiming.tsx)

  • Claim Prizes: Secure prize claiming interface
  • Status Checking: Real-time claim status
  • Transaction Verification: Blockchain transaction verification

4. Platform Integration (PlatformIntegration.tsx)

  • Devfolio Integration: Seamless Devfolio platform integration
  • MLH Integration: Major League Hacking integration
  • Custom Platforms: Support for custom platform integrations

5. Wallet Connection (ConnectWallet.tsx)

  • Multi-Wallet Support: Pera, Defly, and other wallets
  • Connection Management: Secure wallet connection handling
  • Account Management: User account and address management

Development Commands

# Start development server
npm run dev

# Build for production
npm run build

# Run tests
npm test

# Run E2E tests
npm run playwright:test

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

πŸ“š API Documentation

Smart Contract Methods

Simple Prize Distribution

// Create a new distribution
const createDistribution = async (eventName: string, prizeAmount: number, winners: string[]) => {
  const response = await appClient.send.createDistribution({
    args: {
      eventName,
      prizeAmount: BigInt(prizeAmount * 1000000), // Convert to microAlgos
      winners
    }
  });
  return response;
};

// Fund the distribution
const fundDistribution = async (distributionId: number, amount: number) => {
  const response = await appClient.send.fundDistribution({
    args: {
      distributionId: BigInt(distributionId),
      amount: BigInt(amount * 1000000)
    }
  });
  return response;
};

// Claim prize
const claimPrize = async (distributionId: number, amount: number) => {
  const response = await appClient.send.claimPrize({
    args: {
      distributionId: BigInt(distributionId),
      amount: BigInt(amount * 1000000)
    }
  });
  return response;
};

Frontend API

Wallet Integration

import { useWallet } from '@txnlab/use-wallet-react';

const { activeAddress, signer, providers } = useWallet();

// Connect wallet
const connectWallet = async () => {
  await providers[0].connect();
};

// Sign transaction
const signTransaction = async (transaction: Transaction) => {
  return await signer(transaction);
};

πŸš€ Deployment

Frontend Deployment

Vercel (Recommended)

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel --prod

Netlify

# Build the project
npm run build

# Deploy to Netlify
# Upload dist/ folder to Netlify

Smart Contract Deployment

Testnet Deployment

cd projects/algohack-contracts
algokit deploy --target-network testnet

Mainnet Deployment

cd projects/algohack-contracts
algokit deploy --target-network mainnet

Environment Variables

Create .env.localnet, .env.testnet, and .env.mainnet files:

# Algorand Configuration
ALGOD_TOKEN=your_algod_token
ALGOD_SERVER=https://testnet-api.algonode.cloud
ALGOD_PORT=443
INDEXER_TOKEN=your_indexer_token
INDEXER_SERVER=https://testnet-idx.algonode.cloud
INDEXER_PORT=443

# Wallet Configuration
WALLET_CONNECT_PROJECT_ID=your_project_id

πŸ§ͺ Testing

Frontend Testing

# Unit tests
npm test

# E2E tests
npm run playwright:test

# Coverage report
npm test -- --coverage

Smart Contract Testing

# Run all tests
npm test

# Watch mode
npm run test:watch

# Coverage
npm test -- --coverage

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Write comprehensive tests
  • Update documentation
  • Follow the existing code style
  • Ensure all tests pass

πŸ“„ License

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

πŸ™ Acknowledgments

  • Algorand Foundation for the amazing blockchain platform
  • AlgoKit Team for the development framework
  • React Team for the frontend library
  • Tailwind CSS for the styling framework
  • All Contributors who help make this project better

πŸ“ž Support

πŸ”— Links


Built with ❀️ on Algorand

Revolutionizing hackathon prize distribution, one transaction at a time.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages