Avenger

Rent your X banner to advertisers. Set prices, approve ads, earn daily USDC automatically.

Avenger

Created At

ETHGlobal Buenos Aires

Project Description

A marketplace where X (Twitter) users rent their profile banner space to advertisers for passive income. Creators connect their X account, list banner space with custom pricing (e.g., 0.01 USDC/day), and approve rental requests. Advertisers browse listings, upload ads, and pay via x402 (Coinbase CDP). After approval, banners flip automatically via X API. A daily AI cron job verifies ads are still displayed using screenshot comparison and perceptual hashing—if verified, creators receive daily USDC payments automatically; if removed, payments stop and advertisers get refunded. Built with Next.js, Supabase, Coinbase CDP (Embedded Wallets + Server Wallet v2), X OAuth 2.0, Puppeteer, and Sharp. Features secure authentication, automated payments, transparent verification, and full creator control over ad approvals.

How it's Made

How it's made: Built with Next.js 14 (App Router) and TypeScript. The frontend uses React with Coinbase CDP Embedded Wallets for user authentication and wallet management. Supabase stores encrypted OAuth tokens, listings, and rental data with Row Level Security. Payment flow: x402 protocol: Server returns 402 Payment Required with payment requirements. The client-side x402-fetch library intercepts, processes USDC payment via Coinbase CDP, and retries with the transaction hash in the X-PAYMENT header. Server Wallet v2: Automated daily payments use CDP SDK v2. ERC-20 transfers are encoded with ethers.js (transfer(address,uint256)), sent via cdp.evm.sendTransaction() to the USDC contract on Base Sepolia. Banner management: X OAuth 2.0 for authentication (stored encrypted with AES-256-GCM). X API v1.1 for banner updates requires OAuth 1.0a (token_secret). The system handles missing OAuth 1.0a tokens gracefully and returns clear errors. Banner images stored as base64 strings in Supabase (can be migrated to Supabase Storage). Automated verification: Daily cron job (Vercel Cron) uses Puppeteer to screenshot X profiles, Sharp to extract banner regions, and perceptual hashing (pHash) to compare against stored ad images. If verified, sends daily USDC payment; if not, stops payments and refunds the remainder. Notable implementation details: Dual wallet system: Embedded Wallets for users, Server Wallet for automated operations. Async banner flipping: Payment confirmation triggers a background fetch to /api/banner/flip without blocking the response. Type-safe ERC-20 encoding: Uses ethers.js Interface for function encoding instead of manual hex concatenation. Idempotent database migrations: SQL scripts use IF NOT EXISTS and DROP IF EXISTS for safe re-runs. Partner technologies: Coinbase CDP: Simplifies wallet management, enables instant USDC payments, and provides secure server-side transaction signing. Supabase: Handles auth, real-time data, and encrypted storage with minimal setup. Vercel: Serverless functions and cron scheduling for the verification system. The architecture is serverless, automated, and trustless—payments and verification run without manual intervention.

background image mobile

Join the mailing list

Get the latest news and updates