Skip to content

katendravaibhav/Streamchain

Repository files navigation

StreamChain - Decentralized Video Streaming Platform

StreamChain Logo

Censorship-Resistant Video Streaming with P2P Technology, Blockchain Monetization & AI Moderation

License Next.js Solidity IPFS

Overview

StreamChain is a revolutionary decentralized video platform that combines:

  • IPFS for censorship-resistant storage
  • WebTorrent for P2P streaming (70% bandwidth cost reduction)
  • Blockchain for transparent monetization (90% creator revenue share)
  • AI for client-side content moderation
  • DAO for community governance

Key Features

For Creators

  • Uncensored Publishing - Your content on IPFS, nobody can take it down
  • 90% Revenue Share - Keep most of your earnings vs 55-70% on traditional platforms
  • Instant Payouts - Crypto payments, no 30-day holds
  • Full Ownership - You control your content and audience
  • Real-time Analytics - Track views, earnings, and engagement
  • Multiple Revenue Streams - Subscriptions, pay-per-view, tips, super chat

For Viewers

  • Global Access - No geo-restrictions
  • Fast Streaming - P2P technology for faster load times
  • Privacy - No tracking, no data collection
  • Support Creators Directly - 100% of your payment goes to creators
  • Community Governance - Vote on platform decisions with tokens

Technical Highlights

  • Sub-3s Video Start Time via WebTorrent P2P
  • 95%+ NSFW Detection accuracy with TensorFlow.js
  • Multi-Chain Support - Ethereum, Polygon, Base
  • Decentralized Storage - IPFS + Arweave
  • DAO Moderation - Community-driven content review

Architecture

┌─────────────────────────────────────────────────────────────┐
│                        Frontend (Next.js 14)                 │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐   │
│  │  Upload  │  │  Player  │  │Discovery │  │Dashboard │   │
│  └──────────┘  └──────────┘  └──────────┘  └──────────┘   │
└───────────────────────┬─────────────────────────────────────┘
                        │
        ┌───────────────┼───────────────┐
        │               │               │
┌───────▼──────┐ ┌──────▼──────┐ ┌─────▼──────┐
│   IPFS/Web3  │ │  WebTorrent │ │ Blockchain │
│   Storage    │ │  P2P Stream │ │  Contracts │
└──────────────┘ └─────────────┘ └────────────┘
     Pinata          Hybrid CDN      Ethereum
  Web3.Storage       + P2P Seeds    Polygon/Base

Tech Stack

Frontend

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • Web3: Wagmi, Viem, RainbowKit
  • State: Zustand
  • Animations: Framer Motion

Blockchain

  • Smart Contracts: Solidity 0.8.24
  • Libraries: OpenZeppelin
  • Development: Hardhat
  • Networks: Ethereum, Polygon, Base
  • Indexing: The Graph Protocol

Storage & Streaming

  • Decentralized Storage: IPFS (Pinata, Web3.Storage)
  • P2P Streaming: WebTorrent
  • Video Processing: FFmpeg.wasm
  • Player: Video.js

AI/ML

  • Framework: TensorFlow.js
  • NSFW Detection: NSFW.js
  • NLP: Custom hate speech detection
  • Execution: Client-side (privacy-preserving)

Quick Start

Prerequisites

  • Node.js 18+
  • MetaMask or compatible Web3 wallet
  • Pinata account (for IPFS)
  • Alchemy/Infura account (for RPC)

Installation

  1. Clone the repository
git clone https://github.com/yourusername/streamchain.git
cd streamchain
  1. Install dependencies
npm install
  1. Configure environment
cp .env.example .env

Edit .env with your credentials:

# Wallet Connect
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=your_project_id

# RPC Providers
NEXT_PUBLIC_ALCHEMY_ID=your_alchemy_key
NEXT_PUBLIC_INFURA_ID=your_infura_key

# IPFS Storage
NEXT_PUBLIC_PINATA_JWT=your_pinata_jwt
NEXT_PUBLIC_WEB3_STORAGE_TOKEN=your_web3_storage_token

# Contract Addresses (after deployment)
NEXT_PUBLIC_CREATOR_FACTORY_ADDRESS=0x...
NEXT_PUBLIC_DAO_MODERATOR_ADDRESS=0x...
NEXT_PUBLIC_STREAM_TOKEN_ADDRESS=0x...
  1. Compile smart contracts
npm run compile
  1. Deploy contracts (testnet recommended first)
npx hardhat run scripts/deploy.ts --network polygonMumbai
  1. Start development server
npm run dev

Visit http://localhost:3000 🎉

Project Structure

streamchain/
├── app/                      # Next.js 14 app directory
│   ├── layout.tsx           # Root layout
│   ├── page.tsx             # Home page
│   ├── upload/              # Video upload
│   ├── watch/[cid]/         # Video player
│   ├── creator/[address]/   # Creator dashboard
│   └── providers/           # Web3 providers
├── components/              # React components
│   ├── layout/              # Header, Footer
│   ├── video/               # VideoCard, VideoGrid, VideoPlayer
│   └── moderation/          # Moderation UI
├── contracts/               # Solidity smart contracts
│   ├── CreatorContract.sol  # Individual creator contract
│   ├── CreatorFactory.sol   # Factory for creator contracts
│   ├── DAOModerator.sol     # Community moderation
│   └── StreamToken.sol      # Platform token
├── lib/                     # Utility libraries
│   ├── ipfs.ts              # IPFS upload/download
│   ├── webtorrent.ts        # P2P streaming
│   ├── moderation.ts        # AI content moderation
│   └── contracts.ts         # Contract ABIs & addresses
├── hooks/                   # Custom React hooks
├── types/                   # TypeScript types
├── scripts/                 # Deployment scripts
├── test/                    # Contract tests
└── subgraph/                # The Graph subgraph

🔧 Key Components

1. Video Upload Flow

Upload File  AI Moderation  IPFS Upload  Blockchain Registration

2. Streaming Flow

Fetch Metadata  Load via WebTorrent  P2P Distribution  Video.js Player

3. Monetization Flow

Purchase Subscription/PPV  Smart Contract Payment  90% to Creator  10% Platform Fee

Smart Contracts

CreatorContract

  • Manages individual creator's content and subscriptions
  • Handles payments (subscriptions, PPV, tips)
  • 7-day withdrawal delay for dispute resolution

CreatorFactory

  • Deploys new creator contracts
  • Tracks all creators
  • Small deployment fee to prevent spam

DAOModerator

  • Community-based content moderation
  • Token-weighted voting
  • Rewards for accurate moderation
  • 24-hour voting window

StreamToken (ERC20)

  • Platform governance token
  • Used for DAO voting
  • Staking for creator visibility boost
  • 5% APY staking rewards

Usage Examples

Upload a Video

import { uploadToPinata, moderateContent } from '@/lib';

// 1. Moderate content
const modResult = await moderateContent(videoFile, title, description);

// 2. Upload to IPFS
const { cid } = await uploadToPinata(videoFile);

// 3. Register on blockchain
await creatorContract.uploadVideo(cid, price, requiresPayment);

Stream a Video

import { streamVideo } from '@/lib/webtorrent';

const { file } = await streamVideo(magnetURI, (file) => {
  renderToVideo(file, videoElement);
});

Testing

# Run contract tests
npx hardhat test

# Run with coverage
npx hardhat coverage

# Deploy to local network
npx hardhat node
npx hardhat run scripts/deploy.ts --network localhost

Deployment

Blockchain

# Deploy to testnet
npx hardhat run scripts/deploy.ts --network polygonMumbai

# Deploy to mainnet
npx hardhat run scripts/deploy.ts --network polygon

Frontend

# Build for production
npm run build

# Deploy to Vercel
vercel deploy

# Or use Docker
docker build -t streamchain .
docker run -p 3000:3000 streamchain

Metrics & Goals

Year 1 Targets

  • 100K videos uploaded
  • 500K monthly active viewers
  • $1M+ creator earnings
  • 95%+ harmful content detection
  • <3s video start time

Security

  • Smart contracts audited (recommended before mainnet)
  • Client-side AI (no video data sent to servers)
  • 7-day withdrawal delay for disputes
  • Community moderation for edge cases
  • IPFS content addressing (immutable)

Contributing

Contributions welcome! Please read CONTRIBUTING.md first.

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

License

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

Acknowledgments

  • OpenZeppelin for secure smart contract libraries
  • IPFS/Pinata for decentralized storage
  • WebTorrent for P2P streaming technology
  • TensorFlow.js for client-side AI
  • The Graph for blockchain indexing
  • RainbowKit for Web3 wallet integration

Contact & Links

Roadmap

Phase 1 (Q1 2024)

  • Core platform MVP
  • IPFS integration
  • Basic smart contracts
  • WebTorrent streaming

Phase 2 (Q2 2024)

  • DAO governance launch
  • Mobile apps (iOS/Android)
  • Advanced analytics
  • Live streaming beta

Phase 3 (Q3 2024)

  • Multi-language support
  • Enhanced AI moderation
  • Creator tools suite
  • Monetization expansion

Phase 4 (Q4 2024)

  • Cross-platform integration
  • Enterprise features
  • Global CDN nodes
  • V2 protocol upgrade

Built with by the StreamChain community

WebsiteDocumentationDiscord

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors