325 lines
8.7 KiB
Markdown
325 lines
8.7 KiB
Markdown
# π PollCelo - Daily Poll, Daily Celo
|
|
|
|
**The #1 Daily Prediction Market MiniApp on Farcaster using Celo + MiniPay (cUSD)**
|
|
|
|
PollCelo is a viral daily polling app where users vote with tiny cUSD amounts (0.01 - 0.5 cUSD), creating a pot that winners share at the end of the day. Every poll is instantly shareable as a beautiful Farcaster Frame.
|
|
|
|
## π Features
|
|
|
|
### Core Features
|
|
- β
**One Daily Poll** - New poll every day at 00:00 UTC
|
|
- π° **Vote with cUSD** - Tiny amounts (0.01 - 0.5 cUSD) on Celo
|
|
- π **Win Rewards** - 95% of pot shared among winners
|
|
- πΌοΈ **Shareable Frames** - Every poll is a beautiful Farcaster Frame
|
|
- π **Live Results** - Real-time voting progress
|
|
- π **History** - Track your wins and losses
|
|
- π **Turkish Market Focus** - USD/TRY, CBRT, and local content
|
|
- β‘ **Almost Zero Fees** - Thanks to Celo's low transaction costs
|
|
|
|
### π New Features (Just Added!)
|
|
- π **Referral System** - Earn 0.01 cUSD per friend who votes
|
|
- π **Smart Contract** - Trustless voting & automatic payouts
|
|
- π± **Mobile App** - Native iOS & Android app (coming soon)
|
|
|
|
## ποΈ Tech Stack
|
|
|
|
- **Frontend**: Next.js 15, React 19, TypeScript
|
|
- **Styling**: Tailwind CSS
|
|
- **Blockchain**: Celo (cUSD stablecoin)
|
|
- **Wallet**: MiniPay, Wagmi v2, Viem
|
|
- **Farcaster**: Frame SDK, Frame Wagmi Connector
|
|
- **Storage**: Upstash Redis (with in-memory fallback)
|
|
- **OG Images**: @vercel/og
|
|
- **Deployment**: Vercel
|
|
|
|
## π Project Structure
|
|
|
|
```
|
|
daily-poll-mini-app/
|
|
βββ app/
|
|
β βββ layout.tsx # Root layout with metadata
|
|
β βββ page.tsx # Home - today's poll + voting
|
|
β βββ providers.tsx # Wagmi + React Query providers
|
|
β βββ globals.css # Global styles
|
|
β βββ poll/
|
|
β β βββ [id]/
|
|
β β βββ page.tsx # Individual poll detail
|
|
β β βββ layout.tsx # Poll metadata + Frame tags
|
|
β βββ history/
|
|
β β βββ page.tsx # Past polls + user stats
|
|
β βββ success/
|
|
β β βββ page.tsx # Vote confirmation + share
|
|
β βββ api/
|
|
β βββ og/
|
|
β βββ route.tsx # Dynamic OG image generation
|
|
β
|
|
βββ components/
|
|
β βββ Header.tsx # User info + cUSD balance
|
|
β βββ PollCard.tsx # Poll display with progress bars
|
|
β βββ VoteButton.tsx # cUSD amount selector + vote
|
|
β βββ WinnerBadge.tsx # Win/loss display
|
|
β βββ FAB.tsx # Floating action button
|
|
β
|
|
βββ lib/
|
|
β βββ polls.ts # Poll logic + in-memory storage
|
|
β βββ redis.ts # Upstash Redis integration
|
|
β βββ celo.ts # Celo/cUSD config + utils
|
|
β βββ wagmi-config.ts # Wagmi configuration
|
|
β βββ format.ts # Formatting utilities
|
|
β
|
|
βββ types/
|
|
β βββ index.ts # TypeScript types
|
|
β
|
|
βββ public/ # Static assets
|
|
```
|
|
|
|
## π οΈ Setup Instructions
|
|
|
|
### Prerequisites
|
|
|
|
- Node.js 18+ and npm/pnpm/yarn
|
|
- Vercel account (for deployment)
|
|
- Upstash Redis account (optional, free tier)
|
|
- Wallet with cUSD on Celo (for receiving fees)
|
|
|
|
### 1. Clone and Install
|
|
|
|
```bash
|
|
cd daily-poll-mini-app
|
|
npm install
|
|
# or
|
|
pnpm install
|
|
```
|
|
|
|
### 2. Environment Variables
|
|
|
|
Copy `.env.local.example` to `.env.local`:
|
|
|
|
```bash
|
|
cp .env.local.example .env.local
|
|
```
|
|
|
|
Edit `.env.local`:
|
|
|
|
```env
|
|
# Upstash Redis (optional - app works without it)
|
|
UPSTASH_REDIS_REST_URL=https://your-redis-url.upstash.io
|
|
UPSTASH_REDIS_REST_TOKEN=your_token_here
|
|
|
|
# Celo Network
|
|
NEXT_PUBLIC_CELO_RPC_URL=https://forno.celo.org
|
|
NEXT_PUBLIC_CUSD_ADDRESS=0x765DE816845861e75A25fCA122bb6898B8B1282a
|
|
|
|
# Your wallet address (to receive protocol fees)
|
|
PROTOCOL_WALLET_ADDRESS=0xYourWalletAddressHere
|
|
|
|
# App URL (for Frames)
|
|
NEXT_PUBLIC_APP_URL=http://localhost:3000
|
|
```
|
|
|
|
### 3. Run Development Server
|
|
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
Open [http://localhost:3000](http://localhost:3000) in your browser.
|
|
|
|
### 4. Testing in Warpcast
|
|
|
|
1. Install Warpcast mobile app
|
|
2. Enable Developer Mode in Settings
|
|
3. Add your local URL (use ngrok for HTTPS):
|
|
```bash
|
|
ngrok http 3000
|
|
```
|
|
4. Open the ngrok URL in Warpcast
|
|
|
|
## π’ Deployment to Vercel
|
|
|
|
### One-Click Deploy
|
|
|
|
[](https://vercel.com/new/clone?repository-url=https://github.com/yourusername/pollcelo)
|
|
|
|
### Manual Deployment
|
|
|
|
1. Push your code to GitHub
|
|
|
|
2. Import to Vercel:
|
|
```bash
|
|
npx vercel
|
|
```
|
|
|
|
3. Add environment variables in Vercel dashboard
|
|
|
|
4. Deploy:
|
|
```bash
|
|
npx vercel --prod
|
|
```
|
|
|
|
5. Update `NEXT_PUBLIC_APP_URL` to your Vercel domain
|
|
|
|
## π First 7 Poll Ideas (Ready to Use)
|
|
|
|
The app comes with 7 pre-configured polls perfect for Turkish users:
|
|
|
|
1. **Tomorrow 1 USD = ? TL** - Daily currency prediction
|
|
2. **Will BTC break $120K this week?** - Crypto prediction
|
|
3. **FenerbahΓ§e vs Galatasaray** - Derby winner
|
|
4. **Year-end 1 USD = ? TL** - Long-term prediction
|
|
5. **Gold hits $3,000 this month?** - Commodities
|
|
6. **Next CBRT interest rate decision** - Central bank policy
|
|
7. **ETH surpasses $5,000 in December?** - Ethereum prediction
|
|
|
|
## π° Money Flow (How It Works)
|
|
|
|
### Option A: Off-Chain (Launch Today!)
|
|
|
|
1. Users vote by sending cUSD to your `PROTOCOL_WALLET_ADDRESS`
|
|
2. Votes are recorded in Redis/memory
|
|
3. At end of day, manually distribute 95% to winners
|
|
4. Keep 5% as protocol fee
|
|
|
|
**Distribution Script** (manual):
|
|
```javascript
|
|
// See lib/distribute.ts for full implementation
|
|
const winnersPot = totalPot * 0.95
|
|
const protocolFee = totalPot * 0.05
|
|
// Transfer winnersPot proportionally to all winners
|
|
```
|
|
|
|
### Option B: On-Chain (Week 2 Upgrade)
|
|
|
|
Deploy a smart contract to automate distribution:
|
|
|
|
```solidity
|
|
contract PollDistributor {
|
|
function vote(uint256 pollId, uint256 optionId) external payable
|
|
function closePoll(uint256 pollId, uint256 correctOptionId) external
|
|
function distribute(uint256 pollId) external
|
|
}
|
|
```
|
|
|
|
## π¨ Customization
|
|
|
|
### Adding New Polls
|
|
|
|
Edit `lib/polls.ts` and add to `SEED_POLLS`:
|
|
|
|
```typescript
|
|
{
|
|
question: 'Your question here?',
|
|
description: 'Additional context',
|
|
emoji: 'π―',
|
|
options: [
|
|
{ id: 'opt1', text: 'Option 1', emoji: 'β
', votes: 0, totalAmount: 0 },
|
|
{ id: 'opt2', text: 'Option 2', emoji: 'β', votes: 0, totalAmount: 0 },
|
|
],
|
|
}
|
|
```
|
|
|
|
### Changing Vote Amounts
|
|
|
|
Edit `lib/celo.ts`:
|
|
|
|
```typescript
|
|
export const VOTE_OPTIONS = [
|
|
{ amount: 0.01, label: '0.01 cUSD', emoji: 'πͺ' },
|
|
{ amount: 0.05, label: '0.05 cUSD', emoji: 'π°' },
|
|
{ amount: 0.1, label: '0.1 cUSD', emoji: 'π΅' },
|
|
{ amount: 0.5, label: '0.5 cUSD', emoji: 'πΈ' },
|
|
]
|
|
```
|
|
|
|
### Customizing Colors
|
|
|
|
Edit `tailwind.config.ts`:
|
|
|
|
```typescript
|
|
colors: {
|
|
celo: {
|
|
green: '#35D07F',
|
|
yellow: '#FBCC5C',
|
|
dark: '#2E3338',
|
|
},
|
|
}
|
|
```
|
|
|
|
## π§ Troubleshooting
|
|
|
|
### Wallet Not Connecting
|
|
|
|
- Make sure you're testing in Warpcast app (not browser)
|
|
- Check that Frame SDK is initialized: `sdk.actions.ready()`
|
|
- Verify Celo RPC URL is working
|
|
|
|
### Votes Not Recording
|
|
|
|
- Check `PROTOCOL_WALLET_ADDRESS` is set correctly
|
|
- Verify user has enough cUSD + CELO for gas
|
|
- Check browser console for transaction errors
|
|
|
|
### Redis Not Working
|
|
|
|
- App works fine without Redis (uses in-memory storage)
|
|
- Verify Upstash credentials in `.env.local`
|
|
- Check Redis dashboard for connection errors
|
|
|
|
## π Analytics & Monitoring
|
|
|
|
Track key metrics:
|
|
|
|
- **Daily Active Users** - Unique voters per day
|
|
- **Total Volume** - cUSD voted per day
|
|
- **Win Rate** - Percentage of users who win
|
|
- **Viral Coefficient** - Shares per user
|
|
|
|
## π£οΈ Roadmap
|
|
|
|
- [x] Core voting functionality
|
|
- [x] Farcaster Frame integration
|
|
- [x] Real-time results
|
|
- [x] History tracking
|
|
- [ ] Smart contract for auto-distribution
|
|
- [ ] Referral rewards (0.01 cUSD per friend)
|
|
- [ ] Leaderboard
|
|
- [ ] Push notifications for results
|
|
- [ ] Multi-language support
|
|
- [ ] Advanced analytics dashboard
|
|
|
|
## π€ Contributing
|
|
|
|
Contributions welcome! Please:
|
|
|
|
1. Fork the repo
|
|
2. Create a feature branch
|
|
3. Make your changes
|
|
4. Submit a pull request
|
|
|
|
## π License
|
|
|
|
MIT License - see LICENSE file for details
|
|
|
|
## π Support
|
|
|
|
- GitHub Issues: [Report a bug](https://github.com/yourusername/pollcelo/issues)
|
|
- Farcaster: [@yourusername](https://warpcast.com/yourusername)
|
|
- Email: your@email.com
|
|
|
|
## π Ready to Launch?
|
|
|
|
You now have a fully functional daily poll MiniApp that:
|
|
|
|
β
Works on Farcaster with MiniPay
|
|
β
Uses cUSD on Celo (almost zero fees)
|
|
β
Has beautiful shareable Frames
|
|
β
Includes 7 pre-made Turkish market polls
|
|
β
Can be deployed to Vercel in minutes
|
|
|
|
**Let's ship this and get thousands of users voting with cUSD tomorrow! π**
|
|
|
|
---
|
|
|
|
Built with β€οΈ for the Farcaster + Celo community
|
|
# celo-poll
|