celo-poll/DEPLOYMENT.md
2025-12-08 16:31:30 +03:00

7.9 KiB

๐Ÿš€ PollCelo Deployment Guide

Complete guide to deploy PollCelo to production in under 30 minutes.

Prerequisites Checklist

  • GitHub account
  • Vercel account (free tier works)
  • Upstash Redis account (optional, free tier)
  • Celo wallet with address for receiving fees
  • Domain name (optional)

Step 1: Prepare Your Repository

1.1 Push to GitHub

cd daily-poll-mini-app
git init
git add .
git commit -m "Initial commit: PollCelo app"
git branch -M main
git remote add origin https://github.com/yourusername/pollcelo.git
git push -u origin main

2.1 Create Redis Database

  1. Go to Upstash
  2. Sign up / Log in
  3. Click "Create Database"
  4. Choose:
    • Name: pollcelo-prod
    • Type: Regional
    • Region: Choose closest to your users (e.g., us-east-1 for US)
    • TLS: Enabled
  5. Click "Create"

2.2 Get Credentials

  1. Click on your database
  2. Scroll to "REST API" section
  3. Copy:
    • UPSTASH_REDIS_REST_URL
    • UPSTASH_REDIS_REST_TOKEN
  4. Save these for Vercel setup

Step 3: Deploy to Vercel

3.1 Import Project

  1. Go to Vercel Dashboard
  2. Click "Add New..." โ†’ "Project"
  3. Import your GitHub repository
  4. Select the pollcelo repository

3.2 Configure Build Settings

Vercel should auto-detect Next.js. Verify:

  • Framework Preset: Next.js
  • Build Command: npm run build
  • Output Directory: .next
  • Install Command: npm install
  • Root Directory: ./ (or path to daily-poll-mini-app)

3.3 Add Environment Variables

Click "Environment Variables" and add:

# Upstash Redis (optional)
UPSTASH_REDIS_REST_URL=https://your-redis.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 (IMPORTANT!)
PROTOCOL_WALLET_ADDRESS=0xYourCeloWalletAddressHere

# App URL (leave blank for now, update after deploy)
NEXT_PUBLIC_APP_URL=

3.4 Deploy

  1. Click "Deploy"
  2. Wait 2-3 minutes for build to complete
  3. Copy your Vercel URL (e.g., https://pollcelo.vercel.app)

3.5 Update App URL

  1. Go to Settings โ†’ Environment Variables
  2. Edit NEXT_PUBLIC_APP_URL
  3. Set to your Vercel URL: https://pollcelo.vercel.app
  4. Click "Save"
  5. Redeploy: Deployments โ†’ Click โ€ขโ€ขโ€ข โ†’ Redeploy

Step 4: Configure Custom Domain (Optional)

4.1 Add Domain to Vercel

  1. Go to Settings โ†’ Domains
  2. Enter your domain (e.g., pollcelo.com)
  3. Click "Add"

4.2 Update DNS

Vercel will show you DNS records to add:

For root domain (pollcelo.com):

  • Type: A
  • Name: @
  • Value: 76.76.21.21

For www subdomain:

  • Type: CNAME
  • Name: www
  • Value: cname.vercel-dns.com

4.3 Wait for DNS Propagation

  • Usually takes 5-60 minutes
  • Vercel will auto-provision SSL certificate

4.4 Update Environment Variable

  1. Go to Settings โ†’ Environment Variables
  2. Update NEXT_PUBLIC_APP_URL to your custom domain
  3. Redeploy

Step 5: Test in Warpcast

5.1 Install Warpcast Mobile App

5.2 Enable Developer Mode

  1. Open Warpcast
  2. Go to Settings โ†’ Advanced
  3. Enable "Developer Mode"

5.3 Test Your MiniApp

  1. Create a cast with your Vercel URL
  2. Tap the Frame preview
  3. It should open as a MiniApp
  4. Test voting with MiniPay

Step 6: Submit to Warpcast Directory (Optional)

6.1 Prepare Assets

Create these files in your repo:

public/
โ”œโ”€โ”€ icon-192.png      # 192x192 app icon
โ”œโ”€โ”€ icon-512.png      # 512x512 app icon
โ””โ”€โ”€ og-image.png      # 1200x630 OG image

6.2 Submit to Directory

  1. Go to Warpcast Directory
  2. Click "Submit App"
  3. Fill in details:
    • Name: PollCelo
    • Description: Daily polls with cUSD rewards
    • Category: Social, Finance
    • URL: Your production URL
  4. Submit for review

Step 7: Monitor & Maintain

7.1 Vercel Analytics

  1. Enable in Vercel dashboard
  2. Track:
    • Page views
    • Unique visitors
    • Performance metrics

7.2 Upstash Monitoring

  1. Check Redis dashboard
  2. Monitor:
    • Request count
    • Storage usage
    • Errors

7.3 Wallet Monitoring

Check your protocol wallet regularly:

  • Track incoming votes (cUSD received)
  • Distribute winnings to users
  • Withdraw protocol fees

Step 8: Set Up Auto-Distribution (Advanced)

Option A: Manual Daily Script

Create scripts/distribute.ts:

import { getPoll, calculateWinnings } from '@/lib/polls'

async function distributeDailyWinnings() {
  // 1. Get yesterday's poll
  // 2. Calculate all winners
  // 3. Send cUSD proportionally
  // 4. Log transactions
}

distributeDailyWinnings()

Run via cron:

0 0 * * * cd /path/to/app && npm run distribute

Option B: Deploy Smart Contract

See contracts/PollDistributor.sol for automated distribution.

Troubleshooting

Build Fails on Vercel

Error: "Module not found"

  • Check all imports use absolute paths (@/...)
  • Verify tsconfig.json has correct paths

Error: "Environment variable missing"

  • Add all required env vars in Vercel dashboard
  • Make sure NEXT_PUBLIC_ prefix for client-side vars

Frame Not Working in Warpcast

Frame doesn't show

  • Check OG meta tags in /poll/[id]/layout.tsx
  • Verify OG image URL is publicly accessible
  • Use Warpcast Debugger

MiniApp won't open

  • Verify fc:frame tags are correct
  • Check SDK initialization in providers.tsx
  • Enable Developer Mode in Warpcast

Voting Fails

Transaction rejected

  • Check user has enough cUSD + CELO for gas
  • Verify PROTOCOL_WALLET_ADDRESS is correct
  • Test on Celo testnet first (Alfajores)

Vote not recorded

  • Check Redis connection
  • Look at Vercel function logs
  • Verify submitVote() is called correctly

Post-Launch Checklist

  • Deploy to Vercel โœ…
  • Add custom domain
  • Test voting flow end-to-end
  • Share first poll on Warpcast
  • Monitor Vercel analytics
  • Set up daily distribution
  • Submit to Warpcast directory
  • Announce on social media
  • Collect user feedback
  • Plan Week 2 features

Performance Optimization

Enable Edge Functions

In app/api/*/route.ts:

export const runtime = 'edge'

Enable Image Optimization

In next.config.ts:

images: {
  formats: ['image/avif', 'image/webp'],
  deviceSizes: [640, 750, 828, 1080, 1200],
}

Enable Caching

Add to API routes:

export const revalidate = 60 // Cache for 60 seconds

Scaling Considerations

When to upgrade:

  • >1,000 daily users: Upgrade Upstash plan
  • >10,000 daily users: Add Vercel Pro for better analytics
  • >100,000 daily users: Deploy smart contract for auto-distribution
  • >1M daily users: Consider dedicated infrastructure

Security Checklist

  • Never commit .env.local to git
  • Use environment variables for all secrets
  • Validate all user inputs
  • Rate limit API routes
  • Monitor for suspicious transactions
  • Keep dependencies updated
  • Use HTTPS only
  • Enable Vercel DDoS protection

Cost Estimate

Free tier (0-1,000 users/day):

  • Vercel: Free
  • Upstash Redis: Free (10K requests/day)
  • Celo gas: ~$0.001 per transaction
  • Total: ~$0-5/month

Growth tier (1,000-10,000 users/day):

  • Vercel Pro: $20/month
  • Upstash: $10/month (100K requests/day)
  • Celo gas: ~$10/month
  • Total: ~$40/month

Success! ๐ŸŽ‰

Your PollCelo app is now live and ready to get viral on Farcaster!

Next steps:

  1. Share your first poll
  2. Engage with early users
  3. Iterate based on feedback
  4. Scale infrastructure as you grow

Let's get thousands of users voting with cUSD! ๐Ÿš€