πFarcaster Integration
Overview
LendFriend integrates with Farcaster to provide users with a social identity layer on top of their CDP embedded wallet. This integration enhances the user experience by providing human-readable identities, social proof, and reputation while maintaining the security and programmability of CDP wallets.
What is Farcaster?
Farcaster is a decentralized social protocol built on Optimism, not a separate wallet or blockchain. It provides:
FID (Farcaster ID): A unique numerical identifier on the Optimism blockchain
Username (fname): A free, human-readable handle (e.g.,
alice.fcast.iddisplayed as@alice)Social Profile: Bio, avatar, and social connections
Decentralized Social Graph: Portable social relationships across applications
Important Distinctions
Farcaster is NOT:
β A separate wallet
β A separate blockchain
β A token or cryptocurrency
Farcaster IS:
β A social identity layer
β Metadata linked to your existing wallet address
β A portable social profile and reputation system
Architecture
One Wallet, One Social Identity
When users sign up for LendFriend via CDP, they receive:
User Account
βββ CDP Embedded Wallet (Primary)
β βββ EVM Address (0x...)
β βββ Session Keys (for auto-deduction)
β βββ Account Abstraction Features
β
βββ Farcaster Profile (Social Layer)
βββ FID (e.g., 12345)
βββ Username (e.g., alice.fcast.id β @alice)
βββ Profile (bio, avatar)
βββ Social Graph (followers, following)How It Works
Single Address: Users have ONE wallet address from CDP
Linked FID: Farcaster FID is registered and linked to that CDP address
Social Identity: Username and profile provide human-readable identity
Financial Operations: CDP wallet handles all transactions, payments, and auto-deduction
Social Features: Farcaster enables social discovery, reputation, and virality
Registration & Costs
Current State (October 2025+)
Farcaster registration is now FREE:
FID Registration: Free (previously $5-10)
Free Username:
username.fcast.idat no costGas Costs: ~$0.10 per registration (Optimism L2)
Username Options
Free Username (fname)
Format:
username.fcast.idDisplayed as:
@usernameOff-chain registration
Can be changed
Owned by Farcaster protocol
Paid ENS (.eth)
Format:
username.ethOn-chain ownership
Cannot be revoked
Annual renewal fees
User owns the ENS name
Recommendation: Start users with free fnames. They can optionally upgrade to .eth later.
Benefits of Automatic Farcaster Integration
For Users
Human-Readable Identity
@aliceinstead of0x742d...Easier for friends to find and recognize
Social Proof
Profile photo and bio
Follower count and social connections
Reputation history
Better UX
No need to copy/paste addresses
Social discovery features
Familiar social media experience
Portability
Same identity across all Farcaster apps
Not locked to LendFriend
Ownership and control
For LendFriend Platform
Lower Friction
One-step signup process
No separate Farcaster registration needed
Immediate social identity
Network Effects
Users discoverable across Farcaster ecosystem
Viral growth through social connections
Cross-platform user acquisition
Trust & Reputation
Social connections inform trust scoring
Profile history provides context
Anti-Sybil through social graph
Minimal Cost
~$0.10 gas cost per user
Free FID and username
High ROI on user acquisition
Implementation Recommendations
Registration Flow
// When user signs up via CDP OAuth/Email/SMS
async function handleUserSignup(cdpAddress: string, email: string) {
// 1. Create CDP embedded wallet (existing)
const wallet = await createCDPWallet(email);
// 2. Auto-register Farcaster account
const farcasterAccount = await registerFarcasterAccount({
custodyAddress: cdpAddress,
username: generateUsername(email), // e.g., alice123
requestSponsor: true, // Optional: sponsor gas costs
});
// 3. Store FID and username in database
await db.users.update({
address: cdpAddress,
fid: farcasterAccount.fid,
username: farcasterAccount.username,
});
// 4. Continue with normal onboarding
return { wallet, farcasterAccount };
}Username Generation Strategy
function generateUsername(email: string): string {
// Extract name from email
const localPart = email.split('@')[0];
// Sanitize (alphanumeric + hyphens)
const sanitized = localPart.replace(/[^a-zA-Z0-9-]/g, '');
// Add random suffix if needed for uniqueness
const username = `${sanitized}${Math.floor(Math.random() * 1000)}`;
return username.toLowerCase();
}User Customization
After initial signup, allow users to:
Change Username: Switch to a preferred fname
Update Profile: Add bio, avatar, links
Upgrade to ENS: Purchase .eth name (optional)
Connect Existing: Link existing Farcaster account instead of creating new
Technical Details
CDP + Farcaster Integration
Wallet Address
CDP Embedded Wallet
Private Keys
CDP (MPC custody)
Transactions
CDP Wallet
Session Keys
CDP (auto-deduction)
Social Identity
Farcaster
Username
Farcaster
Profile
Farcaster
Social Graph
Farcaster
Security Considerations
Custody: CDP maintains custody of private keys via MPC
Farcaster Keys: Separate signer keys for Farcaster operations
Permissions: Farcaster cannot move funds (no transaction signing)
Recovery: CDP account recovery also maintains Farcaster link
Cost Analysis
Per-User Costs
FID Registration: $0 (now free)
Gas on Optimism: ~$0.10
CDP Account: Free (included in platform)
Total per user: ~$0.10
ROI Calculation
For a 10,000 user base:
Total cost: $1,000 (10K users Γ $0.10)
Benefits:
Social discovery across Farcaster ecosystem
Reduced friction in signup
Better trust scoring via social graph
Viral growth through social connections
User retention through portable identity
Expected ROI: High - minimal cost for significant UX and growth benefits
Migration Path
For Existing Users
Users who already have accounts before Farcaster integration:
Prompt during login: "Add social identity to your account?"
Optional registration: Let users opt-in to create Farcaster profile
Link existing: Allow linking of existing Farcaster accounts
Incentivize: Consider rewards for completing profile
For New Users
Automatic: Create Farcaster account during CDP signup
Seamless: No additional steps required
Transparent: Explain benefits in onboarding
Related Documentation
Conclusion
Recommendation: Implement automatic Farcaster account creation during CDP signup.
The benefits far outweigh the minimal costs (~$0.10/user), and the integration provides:
Better UX with human-readable identities
Social discovery and viral growth
Enhanced trust scoring through social connections
Portable reputation across the Farcaster ecosystem
Farcaster complements CDP's wallet infrastructure by adding a social identity layer without compromising security or introducing wallet fragmentation.
Last updated