A mobile-first NFT marketplace built as a Farcaster Frame, enabling USDC-based trading on Base L2 with instant settlement.
FC NFT Exchange is a decentralized NFT marketplace that lives entirely within Farcaster as a Frame. Users can list, browse, and purchase NFTs using USDC on Base mainnet, all without leaving the Farcaster app.
- π¨ Multi-Standard Support: Seamlessly handles both ERC721 and ERC1155 NFTs
- π° USDC Trading: All transactions use USDC on Base mainnet for stable pricing
- πΌοΈ Frame-Native: Built specifically for the Farcaster Frame environment
- β‘ Real-time Updates: Blockchain events synced via webhooks and scheduled indexing
- π Secure Authentication: Uses Farcaster Quick Auth for seamless sign-in
- π± Mobile-First Design: Optimized for mobile viewing within Farcaster
- Smart Contract: Solidity contract deployed on Base L2 (see
/nft-exchange-contract) - Backend: Cloudflare Workers + Hono framework
- Frontend: Server-side rendering with Custom Elements for interactivity
- Database: Cloudflare D1 (SQLite)
- Storage: Cloudflare R2 for images
- Blockchain Integration: Viem for contract interactions
- Package Manager: Bun
/
βββ src/
β βββ index.js # Main entry point
β βββ server/
β β βββ app.js # API application setup
β β βββ pages.js # Server-side rendered pages
β β βββ db.js # Database queries
β β βββ blockchain.js # Blockchain RPC interactions
β β βββ indexer.js # Event indexing system
β β βββ middleware/
β β β βββ auth.js # Authentication middleware
β β βββ routes/
β β βββ listings.js # NFT listing endpoints
β β βββ users.js # User profile/NFT endpoints
β β βββ activity.js # Activity feed endpoints
β β βββ auth.js # Authentication endpoints
β β βββ webhooks.js # Webhook handlers
β β βββ admin.js # Admin endpoints
β βββ client/
β βββ components/ # Custom Elements
β β βββ frame-provider.js # Frame SDK integration
β β βββ nft-grid.js # NFT display grid
β β βββ nft-details.js # NFT detail modal
β β βββ create-listing.js # Listing creation flow
β β βββ ...
β βββ utils/
β βββ contract.js # Contract encoding (viem)
β βββ transactions.js # Transaction management
βββ nft-exchange-contract/ # Smart contract code
βββ docs/ # Documentation
βββ schema.sql # Database schema
- Server-Side Rendering: Initial page loads are server-rendered for fast performance
- Custom Elements: Client-side interactivity via native Web Components
- Frame Integration: Uses Farcaster Frame SDK for wallet connections and auth
- Event Syncing: Dual approach with Alchemy webhooks + scheduled indexing
- Contract Interactions: Direct on-chain transactions via Frame wallet
GET /api/listings- Browse active listingsGET /api/listings/:id- Get listing detailsGET /api/users/:address/nfts- Get user's NFTsGET /api/users/:address/stats- Get user statisticsGET /api/activity- Get activity feedGET /api/health- Health check
POST /api/listings- Create new listingDELETE /api/listings/:id- Cancel listingGET /api/users/me- Get current user profilePUT /api/users/me- Update profile
POST /api/admin/index-events- Manual blockchain indexingGET /api/admin/index-status- Check indexing statusPOST /api/admin/reindex- Force reindex from block
POST /api/webhooks/alchemy- Alchemy event notifications
The NFT Exchange smart contract is deployed on Base mainnet at:
0x06fB7424Ba65D587405b9C754Bc40dA9398B72F0
See /nft-exchange-contract/README.md for contract details and deployment instructions.
- Bun runtime
- Cloudflare account (Workers, D1, R2)
- Alchemy API key for Base mainnet
- Base ETH for gas fees
Create a .dev.vars file:
# Copy from example
cp .dev.vars.example .dev.vars
# Required variables:
ALCHEMY_API_KEY=your_alchemy_api_key
ADMIN_TOKEN=your_secure_admin_token
DOMAIN=localhost:8787 # or your production domain
ALCHEMY_WEBHOOK_SECRET=your_webhook_secret # optional# Install dependencies
bun install
# Run database migrations
wrangler d1 execute nft-exchange --local --file=./schema.sql
# Start dev server
bun run dev
# Visit http://localhost:8787# Create D1 database
wrangler d1 create nft-exchange
# Update wrangler.toml with the database ID
# Run migrations
wrangler d1 execute nft-exchange --file=./schema.sql# Deploy to Cloudflare Workers
bun run deploy
# Or manually
wrangler deployThe marketplace uses two methods to sync blockchain events:
-
Alchemy Webhooks (Real-time)
- Set up webhook in Alchemy dashboard
- Point to:
https://your-domain.com/api/webhooks/alchemy - Monitor contract:
0x06fB7424Ba65D587405b9C754Bc40dA9398B72F0
-
Scheduled Worker (Every 5 minutes)
- Automatically configured in
wrangler.toml - Catches any missed events
- Provides redundancy
- Automatically configured in
β Core Marketplace
- Browse active NFT listings
- Create listings with on-chain transactions
- Buy NFTs with USDC
- Cancel listings
- Real-time activity feed
β Authentication
- Farcaster Quick Auth integration
- JWT-based session management
- Protected API endpoints
β Blockchain Integration
- Contract interactions via Viem
- USDC & NFT approval flows
- Transaction status tracking
- Event indexing system
β User Experience
- Server-side rendering for fast loads
- Custom Elements for interactivity
- Mobile-optimized design
- Frame SDK integration
π Offer System
- Make offers on any NFT
- Accept/reject offers
- Offer expiration
- Counter-offers
π Enhanced Features
- Collection pages
- Push notifications
π Social Features
- Share functionality
- Show listings by followers
- Trading reputation
The app is configured as a Farcaster Frame with the following metadata:
<meta name="fc:frame" content='{
"version": "next",
"imageUrl": "https://your-domain.com/preview.png",
"button": {
"title": "Browse NFTs",
"action": {
"type": "launch_frame",
"name": "NFT Exchange",
"url": "https://your-domain.com",
"splashImageUrl": "https://your-domain.com/splash.png",
"splashBackgroundColor": "#f8fafc"
}
}
}' />- All contract interactions require user approval
- Admin endpoints protected by bearer token
- CORS enabled only for API routes
- Input validation on all endpoints
- SQL injection prevention via prepared statements
MIT License - see LICENSE file for details