Skip to content

FairDeal is a blockchain-based escrow platform for freelancers, featuring Stellar smart contracts, IPFS file storage, and automated payment release. Zero platform fees, maximum trust.

Notifications You must be signed in to change notification settings

AyushmanGupta21/FairDeal

Repository files navigation

FairDeal - Decentralized Freelance Marketplace

A trustless escrow platform built on Stellar blockchain that enables secure freelance transactions with automated payment workflows, IPFS file storage, and client-side encryption.

Stellar Next.js Soroban


🌟 Features

Smart Contract Escrow

  • Trustless Transactions: Funds locked in Soroban smart contract until work approval
  • Automated Workflows: No intermediaries - smart contract handles fund release/refund
  • Multi-state Management: Created β†’ Submitted β†’ Approved/Cancelled/Revision

Enhanced Security

  • Client-Side Encryption: Files encrypted before IPFS upload using AES-256-CBC
  • Watermarking: Automatic watermark on preview files to prevent unauthorized use
  • Secure Key Management: Encryption keys stored securely, only accessible post-approval

IPFS Storage

  • Decentralized Storage: All work files stored on IPFS via Pinata
  • Encrypted Uploads: Files encrypted before upload for maximum privacy
  • Preview System: Watermarked previews for client review before approval

Seamless UX

  • Freighter Wallet Integration: Connect with Stellar Freighter wallet
  • No Wallet Popups for Non-Payment Actions: Submit work and request revisions without blockchain confirmations
  • Wallet Confirmations Only for Fund Movements: Approve and cancel operations require signatures

πŸ—οΈ Architecture

Tech Stack

Frontend

  • Next.js 14 (App Router)
  • React 18
  • TypeScript
  • Freighter Wallet SDK

Backend

  • Next.js API Routes
  • File-based storage (jobs.json)
  • IPFS (Pinata)

Blockchain

  • Stellar Testnet
  • Soroban Smart Contracts (Rust)
  • Stellar SDK

Storage & Encryption

  • IPFS via Pinata
  • AES-256-CBC encryption
  • Watermarking with Sharp.js

πŸ“ Project Structure

FairDeal(stellar)/
β”œβ”€β”€ app/                          # Next.js App Router
β”‚   β”œβ”€β”€ api/                      # API Routes
β”‚   β”‚   β”œβ”€β”€ jobs/                 # Job management endpoints
β”‚   β”‚   β”œβ”€β”€ upload/               # File upload (IPFS)
β”‚   β”‚   └── download/             # File download (decrypt)
β”‚   β”œβ”€β”€ jobs/[jobId]/             # Job details page
β”‚   β”œβ”€β”€ submit-work/[jobId]/      # Freelancer submission page
β”‚   └── dashboard/                # User dashboard
β”œβ”€β”€ components/                   # React components
β”‚   β”œβ”€β”€ WalletProvider.tsx        # Freighter wallet integration
β”‚   └── ...
β”œβ”€β”€ contract/                     # Soroban smart contract
β”‚   β”œβ”€β”€ src/lib.rs               # Contract logic
β”‚   └── Cargo.toml
β”œβ”€β”€ utils/                        # Utilities
β”‚   β”œβ”€β”€ contract-utils.ts         # Contract interaction
β”‚   β”œβ”€β”€ encryption.ts             # AES encryption
β”‚   └── ipfs.ts                   # IPFS upload/download
β”œβ”€β”€ data/                         # Backend storage
β”‚   └── jobs.json                 # Job metadata
└── .env.local                    # Environment variables

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • Rust & Cargo
  • Stellar CLI (stellar)
  • Freighter Wallet Extension

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/fairdeal.git
    cd fairdeal
  2. Install dependencies

    npm install
  3. Configure environment variables

    Create .env.local:

    # Stellar Configuration
    NEXT_PUBLIC_STELLAR_NETWORK=testnet
    NEXT_PUBLIC_CONTRACT_ID=your_contract_id_here
    
    # Escrow Configuration
    ESCROW_SECRET_KEY=your_escrow_secret_key
    
    # IPFS (Pinata)
    PINATA_API_KEY=your_pinata_api_key
    PINATA_SECRET_API_KEY=your_pinata_secret
    PINATA_JWT=your_pinata_jwt
  4. Build and deploy smart contract

    cd contract
    cargo build --target wasm32-unknown-unknown --release
    stellar contract optimize --wasm target/wasm32-unknown-unknown/release/fairdeal_escrow.wasm
    stellar contract deploy --wasm target/wasm32-unknown-unknown/release/fairdeal_escrow.optimized.wasm --source-account default --network testnet
  5. Update contract ID in .env.local

  6. Run development server

    npm run dev
  7. Open http://localhost:3000


πŸ’Ό Usage

For Clients

  1. Connect Wallet: Click "Connect Wallet" and approve Freighter connection
  2. Post Job: Create job with amount, deadline, and description
  3. Funds Locked: Payment automatically locked in smart contract escrow
  4. Review Work: View watermarked preview when freelancer submits
  5. Decide:
    • Approve & Pay: Release funds to freelancer (requires wallet confirmation)
    • Request Revision: Ask for changes without affecting escrow
    • Cancel Deal: Refund to your wallet (requires wallet confirmation)
  6. Download: Access unencrypted files after approval

For Freelancers

  1. Connect Wallet: Link your Freighter wallet
  2. View Jobs: Browse available jobs on dashboard
  3. Submit Work: Upload files (encrypted automatically before IPFS upload)
  4. No Wallet Popup: Submission happens without blockchain confirmation
  5. Get Paid: Receive payment when client approves (automatic via smart contract)

πŸ” Security Features

Encryption Workflow

  1. Upload: Files encrypted with AES-256-CBC before IPFS upload
  2. Storage: Encrypted files stored on IPFS, keys stored in backend
  3. Preview: Watermarked preview generated for client review
  4. Approval: Original files decrypted and provided to client post-approval

Smart Contract Security

  • Trustless Escrow: Funds held by smart contract, not platform
  • State Validation: Backend validates workflow transitions
  • Authorization: Only job client can approve/cancel
  • No Double-Spend: Contract prevents duplicate approvals

πŸ”— Smart Contract Functions

Function Description Wallet Required?
create_job Lock funds in escrow βœ… Yes
submit_work Mark work as submitted ❌ No (backend only)
approve_work Release funds to freelancer βœ… Yes
cancel_deal Refund client βœ… Yes
get_job Query job details ❌ No
get_job_count Get total jobs ❌ No

πŸ› οΈ Development

Running Tests

npm test                    # Frontend tests
cd contract && cargo test   # Contract tests

Building for Production

npm run build
npm start

Contract Development

cd contract
cargo build --target wasm32-unknown-unknown --release
stellar contract optimize --wasm target/wasm32-unknown-unknown/release/fairdeal_escrow.wasm

πŸ“ Environment Variables

Variable Description Required
NEXT_PUBLIC_STELLAR_NETWORK Stellar network (testnet/mainnet) βœ…
NEXT_PUBLIC_CONTRACT_ID Deployed contract ID βœ…
ESCROW_SECRET_KEY Escrow account secret key βœ…
PINATA_API_KEY Pinata API key βœ…
PINATA_SECRET_API_KEY Pinata secret βœ…
PINATA_JWT Pinata JWT token βœ…

🚧 Roadmap

  • Support for multiple currencies (USDC, XLM)
  • Dispute resolution mechanism
  • Reputation system for freelancers
  • Multi-milestone payments
  • Mobile app (React Native)
  • Mainnet deployment

🀝 Contributing

Contributions are welcome! Please follow these steps:

  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


πŸ“§ Contact

For questions and support, please open an issue or contact your-email@example.com.


Built with ❀️ for the Stellar ecosystem

About

FairDeal is a blockchain-based escrow platform for freelancers, featuring Stellar smart contracts, IPFS file storage, and automated payment release. Zero platform fees, maximum trust.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors 2

  •  
  •