A trustless freelance escrow platform powered by Soroban smart contracts - No backend custody, fully on-chain!
π Smart Contract Deployed: CC67YA4ZKWGNNA2JLS6TUPWFIULCHDWZEHBNQ5G7VDGWJ2TVC7QKWLZ2
- β Smart contract holds escrow (not a backend server!)
- β Automatic fund release via blockchain logic
- β On-chain reputation (fraud flags immutable)
- β Deadline enforcement by contract
- β Zero custody risk - backend can't access funds
# Install dependencies
npm install
# Run the application
npm run dev
# Open browser
http://localhost:3000That's it! Everything (frontend + backend) runs on port 3000.
- Soroban Smart Contract: Funds locked in blockchain contract, not backend server
- No Custody Risk: Contract enforces rules automatically, no human intervention
- Deadline Enforcement: Automatic refunds if deadline passes
- Emergency Release: Freelancers protected from indefinite escrow lock
- On-chain Reputation: Immutable fraud tracking on blockchain
- Split Payments: Initial % to freelancer, remaining locked in smart contract
- Encrypted Files: AES-256-CBC encryption for all submitted work
- Watermarked Previews: Clients can preview work before approval
- Code Execution Sandbox: Auto-preview for code projects (Node.js, Python, Java, HTML)
- IPFS Storage: Decentralized file storage via Pinata
- Fraud Protection: Smart contract-based fraud flag system
- Freighter Wallet: Stellar wallet integration
Create .env.local file in the root directory:
# Stellar Configuration
NEXT_PUBLIC_STELLAR_NETWORK=testnet
NEXT_PUBLIC_CONTRACT_ID=your_contract_id_here
# Escrow Configuration (Server-side only)
ESCROW_SECRET_KEY=your_escrow_secret_key
ESCROW_PUBLIC_KEY=your_escrow_public_key
# Pinata/IPFS Configuration (Server-side only)
PINATA_API_KEY=your_pinata_api_key
PINATA_SECRET_API_KEY=your_pinata_secret_api_key
# Optional: Restore from IPFS on startup
RESTORE_FROM_IPFS_CID=your_ipfs_cid_here- Install Freighter browser extension
- Create or import testnet account
- Get testnet XLM from friendbot: https://laboratory.stellar.org/#account-creator?network=test
npm install
npm run devPrerequisites:
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-unknown-unknown
# Install Soroban CLI
cargo install --locked soroban-cliBuild:
# Windows
.\build-contract.ps1
# Linux/Mac
./build-contract.shDeploy to Testnet:
# Windows
.\deploy-contract.ps1
# Linux/Mac
./deploy-contract.shSee CONTRACT_GUIDE.md for detailed smart contract documentation.
FairDeal/
βββ app/ # Next.js App Router
β βββ api/ # Backend API routes
β β βββ jobs/ # Job management endpoints
β β βββ escrow-address/ # Escrow public key
β β βββ freelancers/ # Fraud flags
β β βββ decrypt-file/ # File decryption
β β βββ ipfs/ # IPFS CID tracking
β β βββ health/ # Health check
β βββ page.tsx # Landing + Dashboard
β βββ login/ # Wallet connection
β βββ create-job/ # Job creation
β βββ jobs/[jobId]/ # Job detail
β βββ submit-work/[jobId]/ # Work submission
βββ components/ # React components
β βββ WalletProvider.tsx # Wallet context
β βββ Navigation.tsx # Navigation bar
βββ lib/ # Server-side utilities
β βββ storage.ts # File-based persistence
β βββ stellar-utils.ts # Stellar blockchain
β βββ ipfs-utils.ts # IPFS & watermarking
β βββ code-execution.ts # Code sandbox
βββ utils/ # Client-side utilities
β βββ stellar-utils.ts # Client Stellar ops
βββ config/ # Configuration
β βββ api.ts # API endpoints config
βββ contract/ # Soroban Smart Contract (Rust)
β βββ src/
β β βββ lib.rs # Main contract logic
β β βββ test.rs # Contract tests
β βββ Cargo.toml # Rust dependencies
βββ data/ # Persistent storage
β βββ jobs.json # Job database
β βββ files.json # File metadata
β βββ fraud.json # Fraud flags
β βββ ipfs-cid.json # Latest IPFS CID
βββ build-contract.ps1 # Build script (Windows)
βββ build-contract.sh # Build script (Linux/Mac)
βββ deploy-contract.ps1 # Deploy script (Windows)
βββ deploy-contract.sh # Deploy script (Linux/Mac)
βββ CONTRACT_GUIDE.md # Smart contract documentation
βββ instrumentation.ts # Server startup logic
βββ next.config.js # Next.js configuration
βββ tsconfig.json # TypeScript config
βββ .env.local # Environment variables
βββ package.json # Dependencies
All backend APIs are available at http://localhost:3000/api/*
POST /api/jobs- Create new jobGET /api/jobs- List all jobsGET /api/jobs/:jobId- Get job detailsGET /api/jobs/:jobId/status- Get job status
POST /api/jobs/submit-work- Submit work filesGET /api/jobs/:jobId/preview- Get preview statusGET /api/jobs/:jobId/preview-content- View watermarked previewGET /api/jobs/:jobId/download- Download original files (approved only)
POST /api/jobs/:jobId/release-initial-payment- Mark initial payment releasedPOST /api/jobs/:jobId/approve- Approve work & release fundsPOST /api/jobs/:jobId/reject- Reject work or request revisionPOST /api/jobs/:jobId/raise-fraud-flag- Raise fraud flag & refund
GET /api/escrow-address- Get escrow public keyGET /api/freelancers/:address/fraud-flags- Get fraud historyPOST /api/decrypt-file- Decrypt fileGET /api/ipfs/latest-cid- Get latest IPFS CIDGET /api/health- Health check
- Connect wallet (Freighter)
- Select "Client" role
- Fill job details:
- Freelancer address
- Amount in XLM
- Initial payment % (10/20/30/50%)
- Deadline
- Description
- Two payments executed:
- Initial % β Freelancer
- Remaining % β Escrow
- Connect wallet
- Select "Freelancer" role
- View assigned jobs
- Upload work files (up to 50 files, 50MB)
- Files automatically:
- Encrypted with AES-256-CBC
- Watermarked for preview
- Uploaded to IPFS
- View watermarked preview
- For code projects: See execution results
- Three options:
- Approve & Pay - Release remaining funds
- Request Revision - Allow resubmission
- Raise Fraud Flag - Terminate & refund
- Clients can raise fraud flags
- Fraud history tracked by freelancer address
- Automatic refund on fraud flag
- Job immediately terminated
- AES-256-CBC encryption for all submitted files
- Random 32-byte keys per file
- Random 16-byte IVs per file
- Keys stored encrypted in file metadata
- "PREVIEW ONLY" text overlay on images
- Opacity reduction for visual indication
- Protects client's intellectual property
- Isolated temporary directories
- 30-second execution timeout
- Automatic cleanup after execution
- Supports: Node.js, Python, Java, HTML
- All transactions on testnet
- Escrow account management
- Transaction memos for tracking
| State | Description | Client Actions | Freelancer Actions |
|---|---|---|---|
| 0 | Created | Wait | Upload Work |
| 1 | Work Submitted | Approve/Reject/Fraud | Wait |
| 2 | Approved | Download Files | - |
| 3 | Rejected/Refunded | - | - |
| 4 | Revision Requested | Wait | Re-upload Work |
- Create Test Job (as Client)
Freelancer: GBT2EHJKQAWW46QRJUY343YGEJDEPIU3U77S2R7ZXLP4NYQFUTGY3PRP
Amount: 10 XLM
Initial Payment: 20% (2 XLM)
Deadline: 7 days
Description: "Create a calculator app"
- Submit Work (as Freelancer)
- Upload HTML/JS calculator files
- Preview shows watermarked version
- Code execution displays calculator
- Review & Approve (as Client)
- View preview
- Test "Approve & Pay" (8 XLM released)
- Verify transaction on Stellar testnet
# Delete .next cache
rm -rf .next
# Reinstall dependencies
rm -rf node_modules package-lock.json
npm install
# Try again
npm run dev- Check
data/jobs.jsonexists - Check console for errors
- Verify wallet connection
- Check file size (max 50MB)
- Check file count (max 50 files)
- Verify PINATA keys in
.env.local
- Verify wallet has enough XLM
- Check testnet friendbot if needed
- Verify ESCROW_PUBLIC_KEY is correct
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel
# Set environment variables in Vercel dashboardAdd all .env.local variables in your hosting platform:
NEXT_PUBLIC_STELLAR_NETWORKNEXT_PUBLIC_CONTRACT_IDESCROW_SECRET_KEYESCROW_PUBLIC_KEYPINATA_API_KEYPINATA_SECRET_API_KEY
- Framework: Next.js 14 (App Router, TypeScript)
- Smart Contract: Soroban (Rust) on Stellar
- Blockchain: Stellar SDK (Testnet/Mainnet)
- Wallet: Freighter API
- Storage: IPFS (Pinata SDK)
- Encryption: Node.js Crypto (AES-256-CBC)
- Watermarking: Jimp
- File Upload: Multer + FormData
- Code Execution: Child Process with timeout
- Persistence: JSON file-based storage + On-chain contract state
- Smart Contract: Escrow logic, fund custody, deadline enforcement
- Backend: IPFS uploads, file encryption, preview generation, metadata
- Smart Contract: Trustless, automatic, transparent, secure
- Backend: Off-chain heavy operations (file processing, watermarking)
The app currently uses backend escrow but is designed to integrate with the smart contract:
- Phase 1 (Current): Backend escrow for MVP testing
- Phase 2 (Production): Smart contract escrow for trustless operation
See CONTRACT_GUIDE.md for integration instructions.
MIT License - Feel free to use this project for learning or building your own freelance platform.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter issues:
- Check the troubleshooting section above
- Review error messages in browser console
- Check server logs in terminal
- Verify environment variables in
.env.local
Built with β€οΈ on Stellar blockchain for secure, transparent freelancing.
Happy freelancing on the blockchain! π