Test your knowledge. Mint your achievement. Engage with the community.
Base Genius is a lightweight, mobile-first mini-app designed for the Base blockchain and Farcaster ecosystem.
๐ฏ What it does:
- Runs a weekly 5-question quiz testing users on recent Base/Farcaster news and community events
- Optimized for mini-app frames and social wallet flows
- Perfect scorers can mint a collectible on-chain badge NFT as proof of knowledge and engagement
๐ก Perfect for:
- Community growth and engagement
- Low-friction educational experiences
- Weekly content updates with minimal overhead
| Feature | Description |
|---|---|
| ๐ฒ Randomized Questions | 5 questions randomly selected from a pool of 50+ |
| ๐ Anti-Cheat | Server-side validation, answers never sent to client |
| ๐ NFT Rewards | Mint on-chain badges for perfect scores |
| ๐ฑ Mobile-First | Optimized for Farcaster frames and social wallets |
| ๐ค AI-Assisted | Weekly question generation using Gemini AI |
| โก Fast & Light | Next.js 16 with TypeScript and Tailwind CSS |
Framework โ Next.js 16 (App Router)
Language โ TypeScript
Styling โ Tailwind CSS
Blockchain โ Base (Ethereum L2)
Web3 Tools โ OnchainKit (wallet & minting)
Data Layer โ JSON-based API routes
Note
All question validation happens server-side to prevent cheating. Correct answers are never sent to the client.
๐ app/ โ Next.js App Router
app/
โโโ ๐ page.tsx # Main game UI & state machine
โโโ ๐ layout.tsx # Root layout
โโโ ๐ globals.css # Global styles
โ
โโโ ๐ api/ # Server-side API routes
โ โโโ questions/route.ts # GET: 5 randomized questions
โ โโโ submit-answers/route.ts # POST: Validate answers
โ โโโ auth/route.ts # Auth helper
โ
โโโ ๐ components/ # React components
โ โโโ QuizCard.tsx
โ โโโ ResultsCard.tsx
โ โโโ MintBadgeButton.tsx
โ โโโ ConnectWallet.tsx
โ
โโโ ๐ data/
โ โโโ quiz-questions.json # 50+ questions with metadata
โ
โโโ ๐ types/
โโโ quiz.ts # TypeScript type definitions
โ๏ธ contracts/ โ Smart Contracts
contracts/
โโโ BaseGeniusBadge.sol # Solidity NFT contract
โโโ BaseGeniusBadgeABI.ts # ABI for app integration
๐ง scripts/ โ Helper Scripts
scripts/
โโโ generate_weekly_questions.py # ๐ค AI question generator
โโโ generate-signer-wallet.ts
โโโ check-contract-signer.ts
๐ผ๏ธ public/metadata/ โ NFT Metadata
public/metadata/
โโโ week-50.json
โโโ week-51.json
โโโ ...
Purpose: Fetch 5 randomized quiz questions
// Response
{
questions: Array<{
id: string;
question: string;
options: string[];
// โ ๏ธ correctAnswer NOT included (anti-cheat)
}>
}Important
Query params support excluding recently served question IDs to prevent repetition.
Purpose: Validate user answers and return detailed results
// Request Body
{
answers: Array<{
questionId: string;
selectedIndex: number;
}>
}
// Response
{
score: number;
results: Array<{
questionId: string;
correct: boolean;
explanation: string;
}>
}graph LR
A[Submit Answers] --> B{Score = 5/5?}
B -->|Yes| C[Show Mint Button]
B -->|No| D[Show Results]
C --> E[Connect Wallet]
E --> F[Mint NFT Badge]
F --> G[Display Success]
| Tool | Version | Required |
|---|---|---|
| Node.js | v18+ | โ Yes |
| npm/pnpm | Latest | โ Yes |
| Ethereum Wallet | - | ๐ง Optional (for testing mints) |
# 1๏ธโฃ Clone the repository
git clone https://github.com/yourusername/base-genius.git
cd base-genius
# 2๏ธโฃ Install dependencies
npm install
# 3๏ธโฃ Set up environment variables
cp .env.example .env
# Edit .env with your API keys
# 4๏ธโฃ Run development server
npm run dev๐ Open http://localhost:3000 in your browser
npm run build
npm startTip
For Farcaster mini-app frame compatibility, the app uses useMiniKit() and setFrameReady() hooks.
Create a .env file from the example template:
cp .env.example .envRequired API Keys:
| Variable | Purpose | Where to Get |
|---|---|---|
GEMINI_API_KEY |
AI question generation | Google AI Studio |
NEYNAR_API_KEY |
Farcaster data fetching | Neynar Dashboard |
Warning
Never commit .env files to version control. These keys should remain secret.
๐ More details: See docs/ai-setup-guide.md for complete setup instructions.
The app includes an AI-powered script to generate fresh quiz questions weekly.
# Create virtual environment
python3 -m venv .venv
# Activate (Linux/Mac)
source .venv/bin/activate
# Activate (Windows)
.venv\Scripts\activate
# Install dependencies
pip install -r scripts/requirements.txtpython3 scripts/generate_weekly_questions.pyWhat it does:
- โ๏ธ Generates new questions using Gemini AI
- ๐ Updates
data/quiz-questions.json - ๐ผ๏ธ Creates metadata files in
public/metadata/ - ๐ Validates question format and structure
Tip
Set up a GitHub Action to run this weekly for automated content updates!
| Requirement | Description |
|---|---|
| ๐ฏ Perfect Score | User must answer all 5 questions correctly |
| ๐ Connected Wallet | Must connect wallet via OnchainKit |
| โ๏ธ Base Network | NFT mints on Base blockchain |
lib/nftService.ts โ Core minting logic
components/MintBadgeButton.tsx โ UI component
contracts/BaseGeniusBadge.sol โ Smart contract
public/metadata/week-*.json โ NFT metadata
๐ Complete guide: NFT_SETUP_INSTRUCTIONS.md
Covers:
- Contract deployment
- Configuration
- Metadata setup
- Testing
npm run build # Catches TypeScript errors| Area | Test Type | Priority |
|---|---|---|
| ๐ Question validation | Unit tests | High |
| ๐ Shuffling logic | Unit tests | High |
| ๐ API routes | Integration | Medium |
| ๐จ UI components | Component tests | Low |
Note
Test suites not included by default. Add your preferred testing framework (Jest, Vitest, etc.).
- ๐ฎ Game State: Uses
useStatefor simple state machine (welcomeโloadingโquizโresults) - ๐ซ No Redux/Zustand: Keep it lightweight for mini-app performance
- ๐จ Tailwind CSS: Utility-first approach
- ๐ฑ Mobile-First: Designed for Farcaster frames
- โจ Consistency: Use design tokens for colors and spacing
- ๐ Server-Side Validation: All answer checking happens on the server
- ๐ฒ Fisher-Yates Shuffle: Random question selection
- ๐ซ No Client-Side Answers: Correct answers never sent to client
Important
When changing API routes, always update types/quiz.ts to maintain type safety.
Quick reference to the most important files in the codebase:
| File | Purpose | Priority |
|---|---|---|
app/page.tsx |
Main game UI & state transitions | ๐ด Critical |
app/api/questions/route.ts |
Question randomization & serving | ๐ด Critical |
app/api/submit-answers/route.ts |
Server-side answer validation | ๐ด Critical |
data/quiz-questions.json |
Question pool (50+ questions) | ๐ด Critical |
lib/nftService.ts |
Minting & Web3 integration | ๐ก Important |
contracts/BaseGeniusBadge.sol |
NFT smart contract | ๐ก Important |
components/QuizCard.tsx |
Quiz UI component | ๐ข Reference |
components/MintBadgeButton.tsx |
Minting UI component | ๐ข Reference |
โ Questions not showing
Check:
- โ
Verify
data/quiz-questions.jsonis valid JSON - โ
Confirm API route is accessible at
/api/questions - โ Check browser console for network errors
- โ Ensure at least 5 questions exist in the pool
Quick test:
curl http://localhost:3000/api/questionsโ Minting fails
Check:
- โ
Contract address configured in
minikit.config.ts - โ Signer wallet properly configured
- โ User connected to Base network
- โ User has sufficient ETH for gas fees
Debug command:
npx ts-node scripts/check-contract-signer.tsโ TypeScript errors
Solutions:
# Clear cache and reinstall
rm -rf .next node_modules
npm install
# Run type check
npm run build-
Testing Suite
- Add Jest/Vitest for unit tests
- Test API validation flow
- Test question shuffling logic
-
CI/CD Pipeline
- GitHub Actions for
npm run build - ESLint and TypeScript checks on PRs
- Automated deployment previews
- GitHub Actions for
-
Automated Content
- Weekly cron job for question generation
- Auto-commit generated questions
- Scheduled metadata updates
-
Analytics
- Track quiz completion rates
- Monitor minting success rates
- User engagement metrics
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
Built with โค๏ธ for the Base & Farcaster community