Fragment
Get paid to run AI tasks on your Mac. Set it, forget it, earn automatically.
Problem Statement
Fragment transforms idle Mac computers into paid AI workers, creating a decentralized network where computing power meets opportunity.Here's how it works: Companies and developers submit AI moderation tasks (like content safety screening) through our web platform. These tasks are broken into smaller pieces and distributed across our network of Mac computers. Mac owners run our lightweight app, which processes these tasks locally using built-in AI models, then automatically earns rewards for each completed task.Why this matters:For Mac Owners: Turn your computer's idle time into passive income. No cloud uploads, no data leaves your device, and everything runs locally. Just install, start the worker, and earn automatically. Your Mac does the work while you sleep, browse, or work on other things.For Businesses: Access affordable, scalable AI processing without building expensive infrastructure. Pay only for completed tasks, get results in minutes, and benefit from a distributed network that's more resilient than centralized servers. Perfect for content moderation, text classification, and other AI-intensive operations.The technology behind Fragment ensures privacy (data processed locally on workers' machines), transparency (all payments recorded on blockchain), and reliability (tasks automatically reassigned if workers go offline). We're making AI compute accessible to everyone—whether you need processing power or want to earn by providing it.Fragment democratizes AI infrastructure, turning every Mac into a potential node in the world's most private, distributed compute network.
Solution
Fragment is built as a full-stack decentralized system with three main components that work together seamlessly:Frontend (Next.js + React + TypeScript)Built a real-time job submission and monitoring interface that polls for task updates every 2 seconds. The UI displays live progress as workers pick up and complete tasks, showing all blockchain transaction hashes and Filecoin storage URLs. Users can select from existing Filecoin datasets or upload new CSV files, with instant cost calculations based on fragment count.Smart Contracts (Solidity on SAGA Chainlet)Deployed FragmentJobRouter.sol on a custom SAGA chainlet, which handles the entire job lifecycle. The contract auto-assigns tasks to workers using an on-chain algorithm that runs during worker registration and result submission. Workers stake their reputation, jobs prepay bounties (0.01 wSAGA per task), and payments execute automatically on-chain when tasks complete. We integrated with the real Wrapped SAGA Dollar (wSAGA) token instead of creating a mock—this required bridging SAGA tokens from SagaEVM to our custom chainlet using Hyperlane's cross-chain messaging protocol.Backend API (Node.js + Express.js + ethers.js)This is the critical integration layer that ties everything together. It manages job creation, uploads data to Filecoin, interacts with smart contracts, and coordinates between the frontend and worker apps. The trickiest part was optimizing blockchain RPC calls—initially, the API made 180+ calls per request, causing 30+ second response times. We solved this with aggressive caching (10-second cache for worker data, 30-second cache for available tasks) and limiting task scans to only the most recent 20 tasks. We also removed transaction confirmation waits from registration and task completion endpoints, sending transactions to the mempool and returning immediately for a snappy UX.Filecoin Storage (Synapse SDK)All task data and results are stored permanently on Filecoin using the Synapse SDK. Here's where we got creative: the SDK's direct upload functionality was unreliable in our Node environment, so we built a wrapper that shells out to a working upload.js script, properly escaping CSV content with quotes and handling file paths with spaces. For downloads, we completely bypassed the SDK—we construct CDN URLs directly (https://[wallet].calibration.filbeam.io/[CID]) and fetch with standard HTTP requests, which is 10x faster than using the SDK's download methods.MacOS Worker App (Swift + SwiftUI + llama.cpp)This is where the magic happens. The app runs a local llama.cpp server hosting the Gemma 3 4B model (quantized to Q4_0 for efficiency). Workers poll the API for available tasks, download input text directly from Filecoin's CDN, run AI inference locally (text safety classification), and submit results back to the blockchain. We initially had a single-worker design but refactored to support 10 concurrent workers, each with its own wallet and balance tracking. The AI inference happens entirely on-device using the ChatService that communicates with the llama.cpp server—no cloud APIs, ensuring complete privacy.Hacky but Clever Solutions:Worker Wallet Generation: Created 10 pre-funded worker wallets stored in worker-wallets.json, each with MENT for gas. The MacOS app cycles through these wallets to simulate a multi-worker network for demos.Instant Blockchain Responses: Removed allawait tx.wait()calls from worker registration and task completion. Transactions are sent to the blockchain and we return immediately, making the API feel instant while blockchain confirmations happen in the background.CSV Upload Workaround: Filecoin's dataset system was designed to append data, but we needed new datasets per upload. Due to fund limitations, we couldn't create new datasets, so we embraced appending—all uploads go to dataset 2216. Not ideal, but it works for the demo and saved us significant Filecoin FIL costs.Result CID Format Hack: Instead of uploading result content to Filecoin (which costs money and time), workers submit a deterministic CID format like "result-safe-task-186" or "result-unsafe-task-187". The API parses this string to extract the classification, avoiding unnecessary Filecoin uploads while maintaining the interface contract.Task Assignment Caching: The smart contract's auto-assignment function is expensive to call. We cache the "available tasks" endpoint for 30 seconds and invalidate it only when tasks are completed, reducing redundant blockchain queries by 95%.Partner Technology Benefits:SAGA Protocol: Custom chainlet gave us dedicated block space with 2-second block times and predictable gas costs. Deploying on a shared chain would have been slower and more expensive.Filecoin (via Synapse SDK): Permanent, decentralized storage for all task data. The CDN feature is killer—we get instant HTTPS access to any stored content, making it perfect for our workers to download tasks quickly.Hyperlane: Enabled us to bridge SAGA Dollar from SagaEVM to our custom Fragment chainlet, creating the wSAGA token. This gave us real economic value instead of test tokens.The entire system processes tasks end-to-end in under 10 seconds: submit job → upload to Filecoin → write to blockchain → worker downloads → AI inference → submit result → receive payment. All fully decentralized, all verifiable on-chain.
Hackathon
ETHGlobal Buenos Aires
2025
Prizes
- 🏆
Best dApp built on Saga Chainlet1st place
Saga
Contributors
- atharvalade
67 contributions