Skip to content

Maathis/Crund

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CreatorGoalDistributor - Web3 Creator Platform

A decentralized platform that enables creators to set up multiple funding goals and receive tips from fans. The platform uses PYUSD (PayPal USD) stablecoin for payments and distributes funds across different goals based on predefined percentages.

🌟 Features

Smart Contract Features

  • Multi-Goal Distribution: Creators can set up multiple funding goals with different targets and percentages
  • Automatic Fund Distribution: Tips are automatically split across active goals based on their percentages
  • Goal Management: Create, track, and claim goals with comprehensive metadata support
  • Creator Registration: Username-based creator system with metadata URI support
  • Secure Payments: Built on PYUSD stablecoin with reentrancy protection

Frontend Features

  • πŸ”— Web3 Integration - Connect wallets with RainbowKit and Wagmi
  • πŸ“± Responsive Design - Modern UI with glassmorphism effects
  • πŸ—ƒοΈ IPFS Storage - Decentralized file storage using Irys
  • ⛓️ Smart Contract Integration - Deploy and interact with contracts on Sepolia

πŸ—οΈ Project Structure

Crund/
β”œβ”€β”€ hardhat/                 # Smart contract development
β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   └── CreatorGoalDistributor.sol
β”‚   β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ test/
β”‚   β”œβ”€β”€ hardhat.config.js
β”‚   └── package.json
└── website/                 # Next.js frontend
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ app/
    β”‚   β”œβ”€β”€ components/
    β”‚   └── lib/
    β”œβ”€β”€ public/
    └── package.json

πŸš€ Quick Start

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • Git
  • MetaMask or compatible Web3 wallet
  • Sepolia testnet ETH for gas fees
  • PYUSD tokens on Sepolia testnet

1. Clone the Repository

git clone <repository-url>
cd Crund

2. Smart Contract Setup

Navigate to the hardhat directory and install dependencies:

cd hardhat
npm install

Create a .env file in the hardhat directory:

# .env
SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_API_KEY
PRIVATE_KEY=your_private_key_here

Deploy the contract to Sepolia:

npm run deploy

Important: Save the deployed contract address and PYUSD token address for the frontend configuration.

3. Frontend Setup

Navigate to the website directory:

cd ../website
npm install

Create environment variables:

cp env.example .env

Fill in your .env file:

# .env
IRYS_RPC_URL=https://testnet-rpc.irys.xyz/v1/execution-rpc

# WalletConnect Project ID (get from https://cloud.walletconnect.com/)
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=your-walletconnect-project-id

# Add your deployed contract address and PYUSD address
NEXT_PUBLIC_CONTRACT_ADDRESS=your_deployed_contract_address
NEXT_PUBLIC_PYUSD_ADDRESS=pyusd_token_address_on_sepolia

4. Run the Development Server

npm run dev

Open http://localhost:3000 to view the application.

πŸ”§ Smart Contract Details

CreatorGoalDistributor Contract

The main contract implements a sophisticated goal-based funding system:

Key Functions

  • registerCreator(metadataURI, username): Register as a creator with metadata and unique username
  • createGoal(name, metadataURI, target, percentage): Create funding goals with specific targets and percentage allocations
  • tip(creatorAddr, amount): Send tips to creators (automatically distributed across active goals)
  • claimGoal(goalIndex): Claim funds when a goal is reached
  • getActiveGoals(creator): Retrieve all active goals for a creator
  • getOldGoals(creator): Retrieve completed/claimed goals

Contract Features

  • Maximum 20 goals per creator
  • Percentage-based fund distribution (total percentages must not exceed 100%)
  • Automatic remainder distribution to creator when tips exceed goal allocations
  • Goal completion tracking with events
  • Username-based creator lookup
  • Reentrancy protection for secure transactions

Events

  • CreatorRegistered: When a new creator registers
  • GoalCreated: When a new goal is created
  • TipReceived: When a tip is received and distributed
  • GoalReached: When a goal reaches its target
  • GoalClaimed: When a creator claims a completed goal

🎨 Frontend Architecture

Tech Stack

  • Framework: Next.js 15 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS with Framer Motion animations
  • Web3: Wagmi v2, RainbowKit, Viem
  • Storage: Irys for decentralized file storage
  • State Management: TanStack Query for server state

Key Components

  • Web3Provider: Wraps the app with Web3 context
  • CreateModal: Main interface for creator registration and goal creation
  • WalletConnection: RainbowKit integration for wallet management

πŸ” Security Features

  • ReentrancyGuard: Prevents reentrancy attacks
  • Ownable: Contract ownership management
  • Input Validation: Comprehensive parameter validation
  • Safe Math: Built-in overflow protection
  • Access Control: Creator-only functions with proper authentication

πŸ“± Usage Guide

For Creators

  1. Connect Wallet: Use the "Create" button to connect your Web3 wallet
  2. Register: Provide username and metadata URI for your creator profile
  3. Create Goals: Set up multiple funding goals with specific targets and percentages
  4. Receive Tips: Fans can tip you, and funds are automatically distributed across your goals
  5. Claim Goals: When a goal reaches its target, claim the funds

For Fans

  1. Connect Wallet: Connect your Web3 wallet to the platform
  2. Browse Creators: Find creators by username
  3. Send Tips: Send PYUSD tokens to support your favorite creators
  4. Track Progress: Monitor goal progress and completion

πŸ§ͺ Testing

Smart Contract Tests

cd hardhat
npx hardhat test

Frontend Development

cd website
npm run dev

πŸš€ Deployment

Smart Contract Deployment

  1. Configure your .env file with Sepolia RPC URL and private key
  2. Ensure you have Sepolia ETH for gas fees
  3. Run the deployment script:
npm run deploy

Frontend Deployment

  1. Build the production version:
npm run build
  1. Deploy to your preferred platform (Vercel, Netlify, etc.)

πŸ”— Network Configuration

  • Testnet: Sepolia
  • Token: PYUSD (PayPal USD) on Sepolia
  • Storage: Irys decentralized storage
  • RPC: Configured via environment variables

πŸ“‹ Environment Variables

Hardhat (.env)

SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_API_KEY
PRIVATE_KEY=your_private_key_here

Frontend (.env)

IRYS_RPC_URL=https://testnet-rpc.irys.xyz/v1/execution-rpc
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=your-walletconnect-project-id
NEXT_PUBLIC_CONTRACT_ADDRESS=your_deployed_contract_address
NEXT_PUBLIC_PYUSD_ADDRESS=pyusd_token_address_on_sepolia

πŸ“„ License

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


Built for EthGlobal Online 2025 🌍

About

My project for the online hackathon EthGlobal 2025

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published