演示受 Base Verify 保护的 airdrop 索赔申请。
A Next.js mini app demonstrating Base Verify integration for social account verification and airdrop claiming. This demo shows how to verify users' social accounts (X/Twitter, Coinbase, Instagram, TikTok) without requiring them to share credentials, while preventing Sybil attacks through deterministic tokens.
Base Verify allows users to prove ownership of verified accounts on major platforms without sharing credentials. Your app receives a deterministic token that enables Sybil resistance—one verified account = one token = one claim, regardless of how many wallets a user connects.
Why This Matters: Even if a wallet has few transactions, Base Verify reveals if the user is high-value through their verified social accounts (X Blue, Instagram followers, TikTok engagement) or Coinbase One subscription. This lets you identify quality users regardless of on-chain activity.
The verification token is the key to preventing duplicate claims:
Token: abc123Token: abc123 (same token!)Token Properties:
claim_airdrop vs join_allowlist)model VerifiedUser {
id String @id @default(cuid())
address String @unique // Wallet address
baseVerifyToken String? @unique // Verification token from Base Verify
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("verified_users")
}Why These Constraints Matter:
address is unique: Prevents the same wallet from claiming multiple timesbaseVerifyToken is unique: This is the anti-sybil protectionExample Sybil Attack Prevention:
User connects Wallet A → verifies X account → gets Token: abc123 → Claims airdrop ✅
User connects Wallet B → verifies SAME X account → gets Token: abc123 → Database rejects (duplicate token) ❌Traits are specific attributes of provider accounts you can verify. Examples:
X (Twitter):
verified:eq:true - Has blue checkmarkverified_type:eq:blue - Specific verification typefollowers:gte:1000 - 1000+ followersCoinbase:
coinbase_one_active:eq:true - Active Coinbase One subscriptioncoinbase_one_billed:eq:true - User has been billed for Coinbase OneInstagram:
followers_count:gte:5000 - 5000+ followersusername:eq:john_doe - Specific usernameTikTok:
follower_count:gte:1000 - 1000+ followersvideo_count:gte:50 - 50+ videoslikes_count:gte:10000 - 10000+ likesCombining Traits (AND logic):
resources: [
'urn:verify:provider:x',
'urn:verify:provider:x:verified:eq:true',
'urn:verify:provider:x:followers:gte:10000'
]
// User must have verified X account AND 10k+ followers/api/verify-token: Verifies signature with Base Verify API and stores user/api/users: Fetches all verified users/api/delete-airdrop: Allows users to delete their claim (requires signature)npm installCreate a .env.local file in the root directory (see .env.example)
# Generate Prisma client
npm run db:generate
# Push schema to database (for development)
npm run db:push
# Or run migrations (for production)
npx prisma migrate deploynpm run devThe app will start on http://localhost:3003
To view/edit database records:
npm run db:studioThe app uses Sign-In with Ethereum (SIWE) messages to communicate verification requirements. SIWE provides:
Example SIWE Message:
{
domain: "your-app.vercel.app",
address: "0x123...",
statement: "Verify your X account",
uri: "https://your-app.vercel.app",
chainId: 8453, // Base mainnet
resources: [
"urn:verify:provider:x", // Which provider to check
"urn:verify:provider:x:verified:eq:true", // Must be verified
"urn:verify:provider:x:followers:gte:1000", // Must have 1000+ followers
"urn:verify:action:claim_airdrop" // Your custom action name
]
}Resource URN Format:
urn:verify:provider:{provider}:{trait_name}:{operation}:{value}Examples:
urn:verify:provider:x:followers:gte:1000 - X account with 1000+ followersurn:verify:provider:coinbase:coinbase_one_active:eq:true - Active Coinbase Oneurn:verify:provider:instagram:followers_count:gt:5000 - Instagram 5000+ followers** Critical: Backend Trait Validation**
Your backend MUST validate that trait requirements in the SIWE message match what your backend expects. This prevents users from modifying trait requirements on the frontend to bypass access controls.
// Backend validation before calling Base Verify
import { validateTraits } from './lib/trait-validator';
const expectedTraits = {
'verified': 'true',
'followers': 'gte:1000'
};
const validation = validateTraits(message, 'x', expectedTraits);
if (!validation.valid) {
return res.status(400).json({ error: 'Invalid trait requirements' });
}
// Now safe to forward to Base Verify APIExample Attack Without Validation:
Secret Key Security:
NEXT_PUBLIC_* environment variables for secretsTo improve UX, signatures are cached in localStorage for 5 minutes:
When a user hasn't verified yet (404 response), redirect them to the Base Verify web app:
function redirectToVerifyWebApp(provider: string) {
const params = new URLSearchParams({
redirect_uri: 'https://your-app.com',
providers: provider, // 'x', 'coinbase', 'instagram', or 'tiktok'
});
const webAppUrl = `https://verify.base.dev?${params}`;
window.location.href = webAppUrl;
}User returns with ?success=true, then check verification again (now returns 200 OK).
Understanding Base Verify API responses:
| Code | Meaning | Action |
|---|---|---|
| 200 OK | User verified and meets all trait requirements | ✅ Store token, grant access |
| 404 Not Found | User hasn't verified this provider yet | Redirect to Base Verify Mini App |
| 400 Bad Request | User verified but doesn't meet trait requirements | ⚠️ Show "Requirements not met" (don't redirect) |
| 401 Unauthorized | Invalid or missing API key | Check your secret key |
Important: Don't retry 400 errors. The user has the account but doesn't meet your requirements (e.g., not enough followers). Retrying won't help unless their account metrics change.
Users can delete their own airdrop claim:
"Delete airdrop for {address}"For more detailed information, see the /docs folder:
Want to integrate Base Verify? Fill out the interest form and we'll reach out with API access.
暂无开放 Issues,或尚未同步最近议题。