Skip to content

Latest commit

Β 

History

History
329 lines (249 loc) Β· 7.09 KB

File metadata and controls

329 lines (249 loc) Β· 7.09 KB

DailyApp V12 - Verification System Guide

πŸ†• What's New in V12

DailyApp V12 adds automated social media verification for tasks on:

  • Farcaster/Base (via Neynar API)
  • Twitter (via Twitter API v2)

Key Features

βœ… Backend Verification Service - Serverless API on Vercel
βœ… Smart Contract Integration - Role-based verification system
βœ… Supported Actions - Follow, Like, Recast/Retweet, Quote, Comment
βœ… Secure - Verifier role with AccessControl


πŸ“ Project Structure

Disco_DailyApp/
β”œβ”€β”€ Disco_DailyApp_contractSolidity.8.20_v.11.01/
β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   └── DailyAppV12Secured.sol    # Updated contract with verification
β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   └── deploy-v12.js              # Deployment script
β”‚   └── ...
└── verification-server/                # NEW: Backend service
    β”œβ”€β”€ api/
    β”‚   └── index.js                   # Express app (Vercel entry)
    β”œβ”€β”€ services/
    β”‚   β”œβ”€β”€ neynar.service.js          # Farcaster verification
    β”‚   β”œβ”€β”€ twitter.service.js         # Twitter verification
    β”‚   └── verification.service.js    # Main orchestrator
    β”œβ”€β”€ routes/
    β”‚   └── verify.routes.js           # API endpoints
    β”œβ”€β”€ config/
    β”‚   └── index.js                   # Configuration
    β”œβ”€β”€ package.json
    β”œβ”€β”€ vercel.json                    # Vercel config
    └── .env.example                   # Environment template

πŸš€ Quick Start

1. Get API Keys

Neynar (Farcaster/Base)

  1. Go to https://neynar.com
  2. Sign up and create an app
  3. Copy your API key

Twitter

  1. Go to https://developer.twitter.com
  2. Apply for developer account
  3. Create a project and app
  4. Generate API keys and bearer token

2. Deploy Smart Contract

cd Disco_DailyApp_contractSolidity.8.20_v.11.01

# Install dependencies
npm install

# Configure environment
cp .env.example .env
nano .env  # Add TOKEN_ADDRESS, PRIVATE_KEY, etc.

# Deploy to testnet
npx hardhat run scripts/deploy-v12.js --network sepolia

Important: Save the deployed contract address and verifier address from the output.

3. Deploy Verification Server

cd ../verification-server

# Install dependencies
npm install

# Configure environment
cp .env.example .env
nano .env  # Add API keys and contract address

# Test locally
npm run dev

# Deploy to Vercel
vercel login
vercel

# Set environment variables in Vercel dashboard

4. Create Verified Tasks

// Connect to deployed contract
const dailyApp = await ethers.getContractAt("DailyAppV12Secured", CONTRACT_ADDRESS);

// Add task requiring Farcaster follow verification
await dailyApp.addTask(
    200,                    // 200 points reward
    86400,                  // 24h cooldown
    0,                      // No tier requirement
    "Follow on Farcaster",
    "https://warpcast.com/yourproject",
    true                    // Requires verification βœ…
);

// Add task requiring Twitter like verification
await dailyApp.addTask(
    150,
    86400,
    0,
    "Like our Tweet",
    "https://twitter.com/yourproject/status/123...",
    true                    // Requires verification βœ…
);

πŸ”„ Verification Flow

1. User completes social action (follow, like, etc.)
   ↓
2. Frontend calls verification API
   POST /api/verify/farcaster/follow
   { userAddress, taskId, fid, targetFid }
   ↓
3. Backend verifies via Neynar/Twitter API
   ↓
4. If verified, backend calls smart contract
   markTaskAsVerified(userAddress, taskId)
   ↓
5. User calls doTask() on contract
   ↓
6. Contract checks verification flag
   ↓
7. Points awarded, verification flag reset

πŸ“‘ API Endpoints

Farcaster

# Follow
POST /api/verify/farcaster/follow
{
  "userAddress": "0x...",
  "taskId": 2,
  "fid": 12345,
  "targetFid": 67890
}

# Like Cast
POST /api/verify/farcaster/like
{
  "userAddress": "0x...",
  "taskId": 3,
  "fid": 12345,
  "castHash": "0x..."
}

# Recast, Quote, Comment - similar structure

Twitter

# Follow
POST /api/verify/twitter/follow
{
  "userAddress": "0x...",
  "taskId": 6,
  "userId": "123456789",
  "targetUserId": "987654321"
}

# Like, Retweet, Quote, Comment - similar structure

πŸ” Security Setup

Grant Verifier Role

const VERIFIER_ROLE = ethers.keccak256(ethers.toUtf8Bytes("VERIFIER_ROLE"));
await dailyApp.grantRole(VERIFIER_ROLE, VERIFIER_WALLET_ADDRESS);

Environment Variables

Smart Contract (.env)

PRIVATE_KEY=your_deployer_private_key
TOKEN_ADDRESS=0x...
INITIAL_OWNER=0x...
VERIFIER_ADDRESS=0x...  # Backend wallet address

Verification Server (.env)

NEYNAR_API_KEY=your_neynar_key
TWITTER_BEARER_TOKEN=your_twitter_bearer_token
CONTRACT_ADDRESS=0x...  # Deployed contract
VERIFIER_PRIVATE_KEY=your_verifier_wallet_key
RPC_URL=https://eth-sepolia.g.alchemy.com/v2/...

πŸ§ͺ Testing

Test Locally

# Terminal 1: Start local blockchain
npx hardhat node

# Terminal 2: Deploy contract
npx hardhat run scripts/deploy-v12.js --network localhost

# Terminal 3: Start verification server
cd verification-server
npm run dev

# Terminal 4: Test API
curl -X POST http://localhost:3000/api/verify/health

Test on Testnet

  1. Deploy to Sepolia
  2. Deploy verification server to Vercel
  3. Create test tasks
  4. Perform social actions
  5. Call verification API
  6. Complete tasks on contract

πŸ“Š Monitoring

Check Verification Status

// Check if task is verified for user
const isVerified = await dailyApp.isTaskVerified(userAddress, taskId);

// Check if user can do task
const [canDo, reason] = await dailyApp.canDoTask(userAddress, taskId);
console.log(canDo ? "Can do task" : `Cannot: ${reason}`);

View Logs

# Vercel logs
vercel logs

# Local logs
# Check console output in terminal

πŸ› Troubleshooting

"Task not verified"

  • User hasn't completed social action
  • Verification API not called
  • Backend verification failed
  • Check API logs

"User does not have VERIFIER_ROLE"

  • Grant VERIFIER_ROLE to backend wallet
  • Check contract address in .env
  • Verify wallet address matches

"Neynar API error"

  • Check API key is valid
  • Verify FID is correct
  • Check rate limits

"Twitter API error"

  • Check bearer token is valid
  • Verify user ID format
  • May need elevated API access

πŸ’‘ Best Practices

  1. Use separate wallet for verifier - Don't use your main wallet
  2. Monitor API costs - Neynar and Twitter may have rate limits
  3. Cache verification results - Avoid duplicate API calls
  4. Implement rate limiting - Prevent spam
  5. Set up alerts - Monitor failed verifications
  6. Test thoroughly - Test all verification types before mainnet

πŸ“ž Support


Built with ❀️ by DailyApp Team

Version 12 - January 2026