A blockchain-based challenge and reward mini-app built for the Farcaster social network. Users can set challenges to each other and earn loot rewards through social interactions.
- Framework: Next.js with React 19.2
- UI Library: shadcn/ui
- CSS Library: TailwindCSS
- Blockchain Integration:
- OnchainKit (Base)
- MiniKit (Farcaster integration)
- Farcaster sdk (for custom Farcaster integration not available in MiniKit)
- Wagmi (Ethereum interactions not available in OnchainKit or MiniKit)
- Smart Contracts: Challenge contract located in
../lootventure-contracts/src/Challenges.sol
- Create challenge by adding description and transferring tokens for loot rewards
- Challenge creator also sets completion deadline and optional users for closed user group challenge
- Challenge creator can set optional verification contract for rules of completion verification process and selection of valid completions
- Rewards can be in form of native token, ERC20, ERC721 or ERC1155 NFTs
- After creating the challenge users publish link to challenge on their Farcaster profile
- From challenge link users can complete the challenge by sending completion url
- link opens completion form where user can reference Farcaster post url or publish new post and use its url for completion
- Users can see list of their challenges
- Users can call smart contract method to payout loot rewards and post to their Farcaster profile
- Farcaster mini-app integration
- Wallet connectivity via MiniKit and OnchainKit
- Responsive UI with shadcn components
The application uses environment variables to configure blockchain connectivity, smart contract addresses, and API keys. Configuration is managed through two main files:
.env- Committed to git, contains production-safe defaults.env.local- Git-ignored, contains developer-specific overrides and secrets.env.example- Committed to git, serves as documentation template
Priority: .env.local > .env
The committed defaults in this repository point to the shared Reef testnet deployment so the app can boot without extra setup.
The application supports multiple blockchain networks through environment variables:
| Environment Variable | Description | Required | Default |
|---|---|---|---|
NEXT_PUBLIC_CHAIN_IDENT_NAME |
Chain identifier (BASE_MAINNET, BASE_SEPOLIA, LOCALHOST, REEF_TESTNET) |
Yes | REEF_TESTNET |
NEXT_PUBLIC_RPC_URL |
Custom RPC endpoint URL | No | CDP Node (if API key set) |
NEXT_PUBLIC_ONCHAINKIT_API_KEY |
Coinbase Developer Platform API key | No | - |
NEXT_PUBLIC_CHALLENGES_CONTRACT_ADDRESS |
Deployed Challenges contract address | Yes | - |
NEXT_PUBLIC_CHALLENGES_CONTRACT_DEPLOYMENT_BLOCK |
Block number where the contract was deployed | No | 53812 |
NEXT_PUBLIC_VERIFIED_CONTRACTS |
JSON array of known verifier contracts for UI display | No | Reef verifier list |
| Chain | Identifier | Chain ID | Default RPC URL | Use Case |
|---|---|---|---|---|
| Reef Testnet | REEF_TESTNET |
13939 |
http://eth.reeftestnet1-reefdevcluster-f70119-72-60-35-83.traefik.me/ |
Shared deployed environment |
| Localhost (Anvil) | LOCALHOST |
31337 |
http://localhost:8545 |
Local development |
| Base Sepolia | BASE_SEPOLIA |
84532 |
https://sepolia.base.org |
Testnet testing |
| Base Mainnet | BASE_MAINNET |
8453 |
https://mainnet.base.org |
Production |
The committed .env already points to the live Reef testnet deployment:
NEXT_PUBLIC_CHAIN_IDENT_NAME=REEF_TESTNET
NEXT_PUBLIC_RPC_URL=http://eth.reeftestnet1-reefdevcluster-f70119-72-60-35-83.traefik.me/
NEXT_PUBLIC_CHALLENGES_CONTRACT_ADDRESS=0xF1F7ef041e0602C40B1F92d41afe6A4C9E114027
NEXT_PUBLIC_CHALLENGES_CONTRACT_DEPLOYMENT_BLOCK=53812You can run the app directly with:
npm run devFor local development with Anvil, create .env.local to override the committed Reef defaults:
-
Copy
.env.exampleto.env.local:cp .env.example .env.local
-
Configure
.env.localfor localhost:# Chain Configuration NEXT_PUBLIC_CHAIN_IDENT_NAME=LOCALHOST NEXT_PUBLIC_RPC_URL=http://localhost:8545 # Contract address will be auto-generated by start-contracts.sh NEXT_PUBLIC_CHALLENGES_CONTRACT_ADDRESS=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
-
Start Anvil and deploy contracts (see Getting Started below)
For testing on Base Sepolia testnet:
-
Deploy contracts to Base Sepolia testnet
-
Update
.env.local:NEXT_PUBLIC_CHAIN_IDENT_NAME=BASE_SEPOLIA NEXT_PUBLIC_RPC_URL=https://sepolia.base.org NEXT_PUBLIC_CHALLENGES_CONTRACT_ADDRESS=0xYourSepoliaContractAddress NEXT_PUBLIC_ONCHAINKIT_API_KEY=your_api_key_here
-
Get testnet ETH from a Base Sepolia faucet
-
Test your application on the testnet
Alternative RPC Providers:
- Alchemy:
https://base-sepolia.g.alchemy.com/v2/YOUR_API_KEY - Infura:
https://base-sepolia.infura.io/v3/YOUR_API_KEY
For production deployment on Base mainnet:
-
Deploy contracts to Base mainnet
-
Set environment variables in your hosting platform (e.g., Vercel):
NEXT_PUBLIC_CHAIN_IDENT_NAME=BASE_MAINNET # Leave NEXT_PUBLIC_RPC_URL unset to use CDP Node NEXT_PUBLIC_ONCHAINKIT_API_KEY=your_production_api_key NEXT_PUBLIC_CHALLENGES_CONTRACT_ADDRESS=0xYourMainnetContractAddress -
Alternatively, use a custom RPC provider:
NEXT_PUBLIC_CHAIN_IDENT_NAME=BASE_MAINNET NEXT_PUBLIC_RPC_URL=https://mainnet.base.org # Or: https://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY # Or: https://base-mainnet.infura.io/v3/YOUR_API_KEY NEXT_PUBLIC_CHALLENGES_CONTRACT_ADDRESS=0xYourMainnetContractAddress
Coinbase Developer Platform (CDP):
- Visit CDP Portal
- Create a project
- Copy your API key to
NEXT_PUBLIC_ONCHAINKIT_API_KEY
Alchemy:
- Visit Alchemy
- Create an app for Base network
- Copy the API key from your app dashboard
Infura:
- Visit Infura
- Create a project and add Base network
- Copy the project ID
Chain ID mismatch error:
- Ensure your wallet is connected to the same network as
NEXT_PUBLIC_CHAIN_IDENT_NAME - Switch your wallet network or update the chain identifier in
.env.local
Cannot connect to RPC:
- For localhost: Ensure Anvil is running (
./_dev-scripts/start-contracts.sh) - For remote: Verify RPC URL is correct and accessible
- Check that API keys are valid and not expired
Contract not found error:
- Verify
NEXT_PUBLIC_CHALLENGES_CONTRACT_ADDRESSmatches the configured chain - Ensure contracts are deployed to the correct network
- Check contract address format (should start with
0x)
Environment variables not updating:
- Restart dev server after changing
.env.local:npm run dev - For production builds, rebuild with
npm run build - Next.js caches environment variables at build/start time
This will also generate ./_dev-scripts/.env-contracts file with deployed contract addresses.
# install nextjs mini-app
npm installnpm run devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
By default, the application uses Coinbase Developer Platform's Node (CDP Node) for blockchain requests, which requires the NEXT_PUBLIC_ONCHAINKIT_API_KEY environment variable. However, you can configure a custom RPC endpoint using the NEXT_PUBLIC_RPC_URL environment variable.
- Local development: Connect to your local Anvil node started by
./_dev-scripts/start-contracts.sh - Custom RPC providers: Use premium or private RPC endpoints (Alchemy, Infura, Ankr, etc.)
- Development/testing: Point to different network environments
Edit .env.local and add or uncomment the NEXT_PUBLIC_RPC_URL variable:
For local development with Anvil:
NEXT_PUBLIC_RPC_URL=http://localhost:8545For production with custom RPC providers:
# Base public RPC
NEXT_PUBLIC_RPC_URL=https://mainnet.base.org
# Alchemy
NEXT_PUBLIC_RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY
# Infura
NEXT_PUBLIC_RPC_URL=https://base-mainnet.infura.io/v3/YOUR_API_KEY- When
NEXT_PUBLIC_RPC_URLis set: OnchainKitProvider uses the custom RPC endpoint - When
NEXT_PUBLIC_RPC_URLis not set: Falls back to CDP Node (requiresNEXT_PUBLIC_ONCHAINKIT_API_KEY) - Chain compatibility: The RPC URL must match the configured chain (Base network)
After changing the RPC URL, restart the development server for changes to take effect.
The ai-docs directory contains comprehensive documentation and best practices organized by technology:
-
farcaster/- Farcaster mini-app integration- Authentication, navigation, wallet integration
- Mini-app context, notifications, and events
- Publishing and discovery guidelines
- SDK API reference and share extensions
-
mini-app/- General mini-app development- Context and navigation patterns
- Design guidelines and best practices
- Embeds, previews, and notifications
- Wagmi wallet integration
-
nextjs/- Next.js framework patterns- Project structure and file system
- Layouts, pages, and routing
- Server and client components
- Data fetching and caching strategies
- Error handling
-
onchain-kit/- OnchainKit components and utilities- Provider setup and configuration
- Transaction components
- MiniKit hooks (authentication, notifications, etc.)
- Theming and formatting utilities
-
react-19.2/- React best practices- Hooks reference (useState, useEffect, etc.)
- Components (Suspense, Fragment, etc.)
- Design patterns and TypeScript usage
- State management and component purity
-
shadcn-ui-lib/- shadcn UI component library- Complete component reference
- Installation and configuration
- Theming and dark mode
- React Hook Form integration
-
wagmi/- Wagmi blockchain interactions- React hooks for contract interactions
- Reading from and writing to contracts
- Transaction handling and chain queries
- Error handling and TypeScript support