A decentralized marketplace for buying and selling encrypted files on Filecoin, with access control powered by Lit Protocol.
- 🔐 Encrypted File Storage: Files are encrypted using Lit Protocol before uploading to Filecoin
- 💰 Marketplace: Buy and sell files with FIL cryptocurrency
- 🔑 Access Control: Smart contract-based access control for purchased content
- 📦 Dataset Management: Organize files in Filecoin datasets
- 🌐 Decentralized: Built on Filecoin Calibration testnet
- Frontend: React + Vite + TanStack Router + Wagmi + RainbowKit
- Smart Contracts: Solidity (Foundry)
- Storage: Filecoin (via Synapse SDK)
- Encryption: Lit Protocol
- Network: Filecoin Calibration Testnet
- Node.js 20+
- npm or yarn
- Foundry (for smart contracts)
- MetaMask or compatible Web3 wallet
- Filecoin Calibration testnet FIL (for testing)
git clone <your-repo-url>
cd filecoin_marketplacecd frontend
npm installcd ../contracts
npm install
forge installCreate a .env file in the frontend directory (if needed for custom RPC endpoints):
VITE_WALLETCONNECT_PROJECT_ID=your_project_idThe contracts are configured for Filecoin Calibration testnet. The Sale contract address is:
0x03996d8d526F82BdE5dD223499946aaf817AE30B
cd frontend
npm run devThe app will be available at http://localhost:3000
cd frontend
npm run buildThe built files will be in the frontend/dist directory.
cd contracts
forge buildforge script script/Deploy.s.sol --rpc-url <calibration-rpc-url> --private-key <your-private-key> --broadcastAfter deploying, update the contract address in contracts/wagmi.config.ts and regenerate the hooks:
cd contracts
npm run wagmi- Click "Connect Wallet" in the header
- Select MetaMask or your preferred wallet
- Switch to Filecoin Calibration testnet if needed
Get test FIL from the Filecoin Calibration Faucet
- Go to your profile
- Click "Upload File"
- If you don't have a dataset, you'll be prompted to create one
- Confirm the transaction
- Click "Upload File"
- Fill in:
- Title: Name of your file
- File: Select file to upload
- Description: Optional description
- Category: Select a category
- Price: Set price in FIL (0 for free)
- Click "Upload"
- Wait for:
- File encryption (if price > 0)
- Upload to Filecoin
- On-chain registration
- Go to the homepage to see all available files
- Use search to filter by seller address
- Click "Buy" to purchase encrypted files
- After purchase, view/download buttons appear
- Files are automatically decrypted using Lit Protocol
- View your purchases in the "Purchased Items" section on your profile
filecoin_marketplace/
├── frontend/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── lib/ # Utilities (Lit Protocol, etc.)
│ │ ├── routes/ # TanStack Router pages
│ │ └── constants/ # App constants
│ ├── public/ # Static assets
│ └── package.json
├── contracts/
│ ├── src/
│ │ └── Sale.sol # Marketplace smart contract
│ ├── script/ # Deployment scripts
│ ├── test/ # Contract tests
│ └── foundry.toml
└── README.md
- React 18: UI framework
- Vite: Build tool
- TanStack Router: File-based routing
- TanStack Query: Data fetching and caching
- Wagmi: Ethereum/Filecoin interactions
- RainbowKit: Wallet connection UI
- Tailwind CSS: Styling
- Shadcn UI: Component library
- Synapse SDK: Filecoin storage operations
- Lit Protocol: File encryption and access control
- Foundry: Smart contract development
- Solidity: Contract language
setContent(uuid, price): Register content for salebuy(creator, uuid): Purchase contentpurchases(buyer, creator, uuid): Check if purchasedgetAllContents(): Get all marketplace itemsgetPurchasedItems(buyer): Get user's purchases
If you encounter memory issues during build:
NODE_OPTIONS='--max-old-space-size=8192' npm run build- Ensure you're on Filecoin Calibration testnet
- Chain ID: 314159
- RPC: https://api.calibration.node.glif.io/rpc/v1
- Ensure you have a dataset created
- Check you have sufficient FIL for gas
- Wait for transactions to confirm (can take 30-60 seconds)
- Ensure you've purchased the file (or are the owner)
- Wait a few moments after purchase for blockchain confirmation
- Check browser console for detailed error messages