This repository contains a design document only. There is no source code here.
Everything below describes an intended architecture. Any performance figure, benchmark, latency target, throughput number or Sharpe ratio in this document is a design target that has never been measured, not a result. Installation and usage instructions describe files that do not exist in this repository.
It is published as a specification and planning artefact. For systems that are actually built and tested, see web3-infrastructure.
A comprehensive collection of Social Finance (SocialFi) implementations — from decentralized social graphs and creator tokenization to content monetization, social trading, on-chain reputation, and full-stack decentralized social media platforms. Built to understand how DeFi meets social media and how users can own, monetize, and govern their digital identity and content.
- Overview
- Why SocialFi?
- SocialFi Ecosystem Landscape
- Tech Stack
- Projects
- How SocialFi Works
- Architecture Diagrams
- Repository Structure
- Getting Started
- Development Workflow
- Testing
- Security
- Deployment
- Key Concepts
- Top SocialFi Tokens
- Resources
- Contributing
- License
SocialFi combines social media with decentralized finance — putting ownership of content, followers, and revenue in the hands of creators and users instead of centralized platforms. Every like, follow, share, and post becomes an on-chain economic action.
What you'll build:
- Decentralized social graphs — own your followers, take them anywhere
- Creator tokens (social tokens) — fans invest in creators via bonding curves
- Content NFTs — posts, articles, and media as ownable, tradeable digital assets
- Tipping and micropayment systems — pay creators directly, no middlemen
- Social trading platforms — copy trades, share alpha, earn from followers
- On-chain reputation — verifiable track record across platforms
- Token-gated communities — exclusive access based on holdings
- Decentralized social media feeds with algorithmic transparency
- DAO-governed social platforms where users set the rules
- Ad revenue sharing — users earn from the attention they generate
| Traditional Social Media | SocialFi |
|---|---|
| Platform owns your content | You own your content as on-chain assets (NFTs) |
| Platform owns your followers | Portable social graph — take followers anywhere |
| Ad revenue goes to the platform | Revenue shared directly with creators and users |
| Opaque algorithmic feeds | Transparent, user-configurable algorithms |
| Deplatforming risk — one entity decides | Censorship-resistant, decentralized moderation |
| Creator monetization: ad splits only | Multiple revenue streams: tips, tokens, NFTs, subscriptions |
| No ownership of your digital identity | Self-sovereign identity owned by the user |
| Data harvested and sold to advertisers | Users control their data and choose what to share |
| Engagement metrics are vanity | Engagement has real economic value (tokens, rewards) |
┌──────────────────────────────────────────────────────────────────────────────┐
│ SOCIALFI ECOSYSTEM │
│ │
│ ┌─────────────────────┐ ┌──────────────────────┐ ┌────────────────────┐ │
│ │ Social Protocols │ │ Creator Tokens │ │ Content Platforms │ │
│ │ │ │ │ │ │ │
│ │ • Lens Protocol │ │ • friend.tech │ │ • Mirror │ │
│ │ • Farcaster │ │ • Stars Arena │ │ • Paragraph │ │
│ │ • CyberConnect │ │ • Pump.fun (social) │ │ • Zora (mint posts)│ │
│ │ • DeSo │ │ • Rally │ │ • Sound.xyz │ │
│ │ • Nostr │ │ • BitClout (legacy) │ │ • Audius │ │
│ └─────────────────────┘ └──────────────────────┘ └────────────────────┘ │
│ │
│ ┌─────────────────────┐ ┌──────────────────────┐ ┌────────────────────┐ │
│ │ Social Trading │ │ Identity & Reputation│ │ Community & DAO │ │
│ │ │ │ │ │ │ │
│ │ • Perpy │ │ • ENS │ │ • Snapshot │ │
│ │ • dYdX leaderboards │ │ • Lens profiles │ │ • Guild.xyz │ │
│ │ • Copin.io │ │ • Farcaster IDs │ │ • Collab.Land │ │
│ │ • SocialBlade (web3) │ │ • Gitcoin Passport │ │ • Hats Protocol │ │
│ │ • Context │ │ • Soulbound tokens │ │ • Jokerace │ │
│ └─────────────────────┘ └──────────────────────┘ └────────────────────┘ │
│ │
│ ┌─────────────────────┐ ┌──────────────────────┐ ┌────────────────────┐ │
│ │ Messaging │ │ Attention Economy │ │ Data & Storage │ │
│ │ │ │ │ │ │ │
│ │ • XMTP │ │ • Brave (BAT) │ │ • Ceramic │ │
│ │ • Push Protocol │ │ • Galxe (campaigns) │ │ • IPFS / Arweave │ │
│ │ • WalletConnect Chat │ │ • Layer3 (quests) │ │ • Lit Protocol │ │
│ │ • Status │ │ • Rabbithole │ │ • Tableland │ │
│ └─────────────────────┘ └──────────────────────┘ └────────────────────┘ │
└──────────────────────────────────────────────────────────────────────────────┘
| Layer | Technology |
|---|---|
| Smart Contracts | Solidity 0.8.x |
| Frameworks | Foundry, Hardhat |
| Social Graph | Lens Protocol, Farcaster Hubs, CyberConnect |
| Token Standards | ERC-20, ERC-721, ERC-1155, ERC-6551, ERC-5192 (SBT) |
| Bonding Curves | Linear, exponential, sigmoid curves for social tokens |
| Messaging | XMTP, Push Protocol, Waku |
| Identity | ENS, Lens Profiles, Farcaster FIDs, Gitcoin Passport |
| Content Storage | IPFS, Arweave, Ceramic, Tableland |
| Access Control | Lit Protocol (token-gating), Guild.xyz |
| Frontend | Next.js, React, wagmi, viem, RainbowKit |
| Indexing | The Graph, Airstack, Neynar (Farcaster) |
| Real-Time | WebSocket, XMTP streams, Farcaster Hubs |
| Networks | Base, Polygon, Arbitrum, Optimism, Ethereum |
| # | Project | Description | Key Concepts |
|---|---|---|---|
| 01 | Decentralized Social Graph | On-chain follow/unfollow with portable follower lists across platforms | Graph data structure, follow NFT, portability |
| 02 | Profile NFT System | Mint your identity as an NFT — username, avatar, bio stored on-chain | ERC-721 profile, metadata, namespace |
| 03 | Post / Publication Contract | Create, edit, and delete on-chain posts with content hashes and timestamps | Content addressing, IPFS pointer, versioning |
| 04 | Social Feed Indexer | Index on-chain social events into a queryable feed (like a timeline) | The Graph, event parsing, pagination |
| 05 | Decentralized Messaging (DMs) | Encrypted peer-to-peer messaging using XMTP or Push Protocol | E2E encryption, XMTP SDK, conversations |
| # | Project | Description | Key Concepts |
|---|---|---|---|
| 06 | Creator Token (Bonding Curve) | Each creator gets a personal token — price rises with demand | Bonding curve, buy/sell, price discovery |
| 07 | friend.tech Clone | Buy "keys" (shares) of creators — price follows supply curve, chat access | Key pricing, share mechanics, gated chat |
| 08 | Fan Token Launchpad | Launch social tokens for creators with configurable curves and fee splits | Token factory, curve selection, royalties |
| 09 | Creator Staking & Rewards | Stake tokens on favorite creators — earn yield when they gain followers | Staking, social metrics oracle, rewards |
| 10 | Social Token Airdrop Engine | Airdrop tokens to followers, early supporters, and community contributors | Merkle airdrop, snapshot, claim system |
| # | Project | Description | Key Concepts |
|---|---|---|---|
| 11 | Content NFT Minting (Collect Posts) | Turn any post/article into a collectible NFT — mint editions for fans | Edition NFT, collect fee, creator revenue |
| 12 | Tipping & Micropayments | Tip creators in any token — per-post, per-comment, or recurring micro-tips | Transfer, fee splitting, small amounts |
| 13 | Subscription / Paywall System | Token-gated premium content — subscribe monthly with stablecoins or tokens | Superfluid streams, access NFT, gating |
| 14 | Ad Revenue Sharing Protocol | Users earn from ads shown to them — attention is tokenized and rewarded | Attention oracle, impression tracking, BAT |
| 15 | Crowdfunding for Content | Fund articles, videos, or projects before creation — refund if not shipped | Milestone-based, escrow, refund mechanism |
| # | Project | Description | Key Concepts |
|---|---|---|---|
| 16 | Copy Trading Protocol | Follow top traders — automatically mirror their on-chain trades | Trade mirroring, fund vault, permissions |
| 17 | Social Leaderboard | Rank traders by PnL, win rate, and Sharpe ratio — on-chain verified | Performance tracking, ranking, Merkle proof |
| 18 | Alpha Sharing Marketplace | Sell trade ideas and alpha calls as token-gated content — pay per view | Content gating, reveal mechanics, ratings |
| 19 | Prediction Reputation System | Track prediction accuracy over time — build verifiable forecasting cred | Brier score, calibration, track record SBT |
| 20 | Social Yield Pool | Community pools where members vote on DeFi strategies together | DAO vault, proposal voting, shared yield |
| # | Project | Description | Key Concepts |
|---|---|---|---|
| 21 | On-Chain Reputation Score | Build reputation from activity — posts, tips received, community votes | Scoring algorithm, decay, SBT |
| 22 | Soulbound Achievement Badges | Non-transferable badges for milestones — 100 posts, 1K followers, OG | ERC-5192, attestation, milestone triggers |
| 23 | Gitcoin Passport Integration | Verify humanity and reputation using Gitcoin Passport stamps | Sybil resistance, stamp verification |
| 24 | Decentralized Moderation DAO | Community-elected moderators vote on content flags and user reports | Staking, jury system, dispute resolution |
| 25 | Cross-Platform Identity Aggregator | Unify your identity across Lens, Farcaster, ENS, and Twitter into one view | Resolver, multi-platform, linked profiles |
| # | Project | Description | Key Concepts |
|---|---|---|---|
| 26 | Decentralized Twitter / Microblog | Post, follow, like, repost — fully decentralized with on-chain social graph | Lens/Farcaster integration, feed algorithm |
| 27 | Token-Gated Community Platform | Exclusive spaces unlocked by holding specific tokens or NFTs | Guild.xyz, Lit Protocol, access control |
| 28 | Decentralized Reddit (Forum) | Subreddit-style communities with upvotes, moderation, and token rewards | Community tokens, karma system, governance |
| 29 | Creator Marketplace | Full platform for creators: profiles, content, subscriptions, analytics | Multi-feature integration, dashboard |
| 30 | SocialFi Mobile App | React Native mobile app — feed, messaging, wallet, creator tokens | Mobile-first, push notifications, UX |
┌─────────────────────────────────────────────────────────────────────────────┐
│ USER LAYER │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Mobile App │ │ Web App │ │ Farcaster │ │ Lens App │ │
│ │ (React Native)│ │ (Next.js) │ │ Frames │ │ Integration │ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
└─────────┼─────────────────┼─────────────────┼─────────────────┼─────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ PROTOCOL LAYER │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Social Graph │ │ Content │ │ Creator │ │ Monetization │ │
│ │ Contract │ │ Registry │ │ Tokens │ │ Module │ │
│ │ │ │ │ │ │ │ │ │
│ │ • follow() │ │ • post() │ │ • buy() │ │ • tip() │ │
│ │ • unfollow() │ │ • comment() │ │ • sell() │ │ • subscribe()│ │
│ │ • getFollowers│ │ • like() │ │ • priceOf() │ │ • collect() │ │
│ │ • getFollowing│ │ • repost() │ │ • totalSupply│ │ • distribute│ │
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Profile NFT │ │ Reputation │ │ Messaging │ │ Governance │ │
│ │ (ERC-721) │ │ (SBT) │ │ (XMTP) │ │ (DAO) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ DATA LAYER │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ IPFS/Arweave │ │ Ceramic │ │ The Graph │ │ Tableland │ │
│ │ (content) │ │ (mutable data)│ │ (indexing) │ │ (SQL on-chain)│ │
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────┐
│ CREATOR TOKEN BONDING CURVE │
│ │
│ Price │
│ │ ╱── │
│ │ ╱───╱ │
│ │ ╱───╱ │
│ │ ╱───╱ │
│ │ ╱───╱ │
│ │ ╱───╱ │
│ │ ╱───╱ │
│ │ ╱───╱ ← Each new share costs more │
│ │ ╱───╱ (supply-driven pricing) │
│ │ ╱───╱ │
│ │ ╱───╱ │
│ │ ╱───╱ │
│ │╱─╱ │
│ └─────────────────────────────────────────────────► Supply │
│ │
│ Formula (friend.tech style): │
│ price = supply² / 16000 │
│ │
│ Example: │
│ ┌──────────┬──────────┬───────────────┬──────────────────┐ │
│ │ Share # │ Buy Price│ Total Cost │ Creator Earnings │ │
│ ├──────────┼──────────┼───────────────┼──────────────────┤ │
│ │ 1 │ 0.0001 Ξ │ 0.0001 Ξ │ 5% fee │ │
│ │ 10 │ 0.006 Ξ │ 0.02 Ξ │ 5% fee │ │
│ │ 50 │ 0.156 Ξ │ 2.6 Ξ │ 5% fee │ │
│ │ 100 │ 0.625 Ξ │ 20.8 Ξ │ 5% fee │ │
│ │ 200 │ 2.5 Ξ │ 166.7 Ξ │ 5% fee │ │
│ └──────────┴──────────┴───────────────┴──────────────────┘ │
│ │
│ Fee Structure: │
│ ┌────────────────────────────────────────────┐ │
│ │ Buy / Sell: │ │
│ │ ├── 5% → Creator (the person's token) │ │
│ │ ├── 5% → Protocol treasury │ │
│ │ └── 90% → Bonding curve reserve │ │
│ └────────────────────────────────────────────┘ │
│ │
│ When you SELL: │
│ • You receive price from the curve minus fees │
│ • Price drops for next buyer (supply decreases) │
│ • Creator still earns their 5% fee on the sell │
└──────────────────────────────────────────────────────────────────────────┘
Creator Smart Contract Fans / Collectors
│ │ │
├── createPost(contentURI) ─►│ │
│ (content on IPFS) │── emit PostCreated ───────────►│
│ │ │
│ │◄── collectPost{value: 0.01Ξ} ─┤
│ │ (Fan 1 mints edition NFT) │
│ │ │
│ │◄── collectPost{value: 0.01Ξ} ─┤
│ │ (Fan 2 mints edition NFT) │
│ │ │
│ │◄── collectPost{value: 0.01Ξ} ─┤
│ │ (Fan 3 mints edition NFT) │
│ │ │
│ Revenue flows: │ │
│ ┌─────────────────────────┤ │
│ │ 3 collects × 0.01 Ξ │ │
│ │ = 0.03 Ξ total │ │
│ │ │ │
│ │ Creator: 0.027 Ξ (90%) │ │
│ │ Protocol: 0.003 Ξ (10%)│ │
│ └─────────────────────────┤ │
│ │ │
│◄── withdraw() ────────────┤ │
│ (0.027 Ξ to creator) │ │
│ │ │
│ PLUS: ongoing royalties │ │
│ when collectors resell │ │
│ the edition NFTs │ │
┌──────────────────────────────────────────────────────────────────────────┐
│ PORTABLE SOCIAL GRAPH │
│ │
│ Traditional (locked-in): SocialFi (portable): │
│ │
│ ┌──────────┐ ┌──────────────────────────┐ │
│ │ Twitter │ 50K followers │ On-Chain Social Graph │ │
│ │ (X) │ ← stuck here │ (Lens / Farcaster) │ │
│ └──────────┘ │ │ │
│ │ Alice follows: │ │
│ ┌──────────┐ │ ├── Bob.lens │ │
│ │ Instagram │ 30K followers │ ├── Carol.eth │ │
│ │ │ ← stuck here │ ├── Dave.fcast │ │
│ └──────────┘ │ └── ... 50K more │ │
│ │ │ │
│ ┌──────────┐ │ Stored as: │ │
│ │ TikTok │ 100K followers │ • Follow NFTs (Lens) │ │
│ │ │ ← stuck here │ • On-chain events │ │
│ └──────────┘ │ • Ceramic streams │ │
│ └────────────┬─────────────┘ │
│ If banned from one platform, │ │
│ you lose everything. │ │
│ ┌──────────┼──────────┐ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌────────┐ ┌────────┐ ┌────────┐ │
│ │ App A │ │ App B │ │ App C │ │
│ │(Twitter │ │(Reddit │ │(TikTok │ │
│ │ clone) │ │ clone) │ │ clone) │ │
│ │ │ │ │ │ │ │
│ │ Same │ │ Same │ │ Same │ │
│ │ 50K │ │ 50K │ │ 50K │ │
│ │followers│ │follwrs │ │follwrs │ │
│ └────────┘ └────────┘ └────────┘ │
│ │
│ Switch apps anytime — your audience comes with you. │
└──────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────┐
│ TOKEN-GATED COMMUNITY │
│ │
│ Access Rules (defined on-chain): │
│ ┌────────────────────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ 🟢 Public Channel → Anyone can read/post │ │
│ │ │ │
│ │ 🟡 Members Channel → Hold ≥ 100 $CREATOR tokens │ │
│ │ ├── General chat │ │
│ │ ├── Announcements │ │
│ │ └── Events │ │
│ │ │ │
│ │ 🟠 VIP Channel → Hold ≥ 1,000 $CREATOR tokens │ │
│ │ ├── Alpha chat │ │
│ │ ├── Early access │ │
│ │ └── 1-on-1 booking │ │
│ │ │ │
│ │ 🔴 Inner Circle → Hold Creator Key (friend.tech style) │ │
│ │ ├── Private group chat │ │
│ │ ├── Direct messages │ │
│ │ └── Revenue sharing │ │
│ │ │ │
│ └────────────────────────────────────────────────────────────────────┘ │
│ │
│ Verification Flow: │
│ User ──► Connect Wallet ──► Check Balance ──► Grant/Deny Access │
│ │ │
│ Lit Protocol or │
│ Guild.xyz verifies │
│ token holdings │
└──────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────┐
│ FRONTEND LAYER │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Feed / Timeline│ │ Profile Page │ │ Creator Token │ │ Messaging │ │
│ │ (posts, likes) │ │ (bio, NFTs) │ │ Trading UI │ │ (DMs, groups)│ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
└─────────┼─────────────────┼─────────────────┼─────────────────┼─────────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────────────────────────────────────────────────────────────────────┐
│ SMART CONTRACTS │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Social Graph │ │ Content │ │ Creator Token │ │ Monetization │ │
│ │ │ │ Registry │ │ (Bonding │ │ │ │
│ │ • Follow NFT │ │ │ │ Curve) │ │ • Tips │ │
│ │ • Connections │ │ • Posts │ │ │ │ • Subscriptions│ │
│ │ • Portability │ │ • Comments │ │ • Buy/Sell │ │ • Collect fees│ │
│ │ │ │ • Reactions │ │ • Pricing │ │ • Ad revenue │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Profile NFT │ │ Reputation │ │ Governance │ │ Paymaster │ │
│ │ (Identity) │ │ (Soulbound) │ │ (Moderation) │ │ (Gasless) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
└──────────────────────────────────┬──────────────────────────────────────────┘
│
┌──────────────────────────────────┼──────────────────────────────────────────┐
│ DATA & INDEXING LAYER │
│ │ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ IPFS/Arweave │ │ Ceramic │ │ The Graph │ │ XMTP │ │
│ │ (content) │ │ (profiles) │ │ (feed index) │ │ (messaging) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────────────────┘
Leader Trader Copy Trading Vault Follower
│ │ │
│ │◄── deposit(100 USDC) ─────┤
│ │ (Follower allocates │
│ │ capital to vault) │
│ │ │
├── swap(ETH → USDC) ─────►│ │
│ on Uniswap │ │
│ │── detect trade ──────────►│
│ │ (mirror proportionally) │
│ │ │
│ │── execute same swap │
│ │ (Follower's 100 USDC │
│ │ portion) │
│ │ │
│ [Trade is profitable] │ │
│ │ │
│ │ Profit: +10 USDC │
│ │ ├── 8 USDC → Follower │
│ │ └── 2 USDC → Leader (20%)│
│◄── performance fee ───────┤ │
│ (2 USDC) │ │
socialfi-projects/
├── 01-decentralized-social-graph/
│ ├── src/
│ │ ├── SocialGraph.sol
│ │ ├── FollowNFT.sol
│ │ └── interfaces/
│ ├── test/
│ │ ├── SocialGraph.t.sol
│ │ └── invariant/
│ ├── foundry.toml
│ └── README.md
├── 06-creator-token-bonding-curve/
│ ├── src/
│ │ ├── CreatorToken.sol
│ │ ├── BondingCurve.sol
│ │ └── libraries/
│ │ └── CurveLib.sol
│ ├── test/
│ └── README.md
├── 07-friendtech-clone/
│ ├── src/
│ │ ├── SocialKeys.sol
│ │ └── KeyPricing.sol
│ ├── test/
│ ├── frontend/
│ │ ├── src/
│ │ └── package.json
│ └── README.md
├── 11-content-nft-collect/
│ ├── src/
│ │ ├── ContentNFT.sol
│ │ ├── EditionMinter.sol
│ │ └── RevenueDistributor.sol
│ ├── test/
│ └── README.md
├── 16-copy-trading/
│ ├── src/
│ │ ├── CopyTradeVault.sol
│ │ ├── TradeDetector.sol
│ │ └── interfaces/
│ ├── test/
│ │ └── fork/
│ └── README.md
├── 26-decentralized-twitter/
│ ├── contracts/
│ ├── frontend/
│ │ ├── src/
│ │ │ ├── components/
│ │ │ │ ├── Feed.tsx
│ │ │ │ ├── PostCard.tsx
│ │ │ │ ├── ProfileHeader.tsx
│ │ │ │ └── ComposeTweet.tsx
│ │ │ ├── hooks/
│ │ │ └── pages/
│ │ └── package.json
│ ├── subgraph/
│ └── README.md
├── lib/ # Shared Solidity dependencies
│ ├── forge-std/
│ ├── openzeppelin-contracts/
│ └── solmate/
├── interfaces/ # Common SocialFi interfaces
│ ├── ISocialGraph.sol
│ ├── ICreatorToken.sol
│ ├── IContentRegistry.sol
│ ├── IReputation.sol
│ └── IMonetization.sol
├── libraries/ # Shared utilities
│ ├── BondingCurveLib.sol
│ ├── ReputationLib.sol
│ ├── ContentHashLib.sol
│ └── FeeLib.sol
└── README.md
- Foundry —
curl -L https://foundry.paradigm.xyz | bash && foundryup - Node.js >= 18.x (for frontends and integrations)
- Git
- MetaMask or any EVM wallet
# Clone the repository
git clone https://github.com/pranay123-stack/socialfi-projects.git
cd socialfi-projects
# Navigate to a project
cd 06-creator-token-bonding-curve
# Install dependencies
forge install
# Build
forge build
# Run tests
forge test -vvvcp .env.example .env# RPC Endpoints
MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY
BASE_RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY
POLYGON_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/YOUR_KEY
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY
# Deployment
PRIVATE_KEY=your_deployer_private_key
ETHERSCAN_API_KEY=your_etherscan_api_key
# Content Storage
PINATA_API_KEY=your_pinata_key
PINATA_SECRET=your_pinata_secret
# Messaging
XMTP_ENV=production
# Indexing
AIRSTACK_API_KEY=your_airstack_key
NEYNAR_API_KEY=your_neynar_key
# Social Protocols
LENS_API_URL=https://api-v2.lens.dev
FARCASTER_HUB_URL=https://hub.farcaster.xyzNever commit private keys or API secrets. All projects include
.gitignorewith.envexcluded.
# Compile
forge build
# Run all tests
forge test
# Run specific test
forge test --match-test testBuyCreatorToken -vvvv
# Gas report
forge test --gas-report
# Deploy
forge script script/Deploy.s.sol --rpc-url $BASE_RPC_URL --broadcast --verify
# Interact with deployed contracts
cast call $CREATOR_TOKEN "priceOf(uint256)" 50 --rpc-url $BASE_RPC_URL
cast send $SOCIAL_GRAPH "follow(address)" $CREATOR --rpc-url $BASE_RPC_URL --private-key $PRIVATE_KEYcd frontend
pnpm install
pnpm dev
# Open http://localhost:3000cd subgraph
graph codegen
graph build
graph deploy --studio socialfi-feed# Unit Tests — individual functions (follow, post, buy token)
forge test --match-path "test/unit/*"
# Integration Tests — full user journey flows
forge test --match-path "test/integration/*"
# Fuzz Tests — random inputs for bonding curves, fee calculations
forge test --match-path "test/fuzz/*"
# Invariant Tests — properties that must always hold
forge test --match-path "test/invariant/*"
# Fork Tests — test against live Lens, Uniswap, etc.
forge test --match-path "test/fork/*" --fork-url $BASE_RPC_URL// Bonding curve: buy then immediate sell must not profit (no arbitrage)
function invariant_noBuySellArbitrage() public {
uint256 buyPrice = curve.getBuyPrice(1);
uint256 sellPrice = curve.getSellPrice(1);
assertGt(buyPrice, sellPrice, "Buy-sell arbitrage exists");
}
// Bonding curve: reserve must always cover all sells at current prices
function invariant_curveReserveSolvent() public {
uint256 totalSellValue = curve.totalSellValue();
uint256 reserve = address(curve).balance;
assertGe(reserve, totalSellValue, "Reserve cannot cover all sells");
}
// Social graph: follower count must match actual follow NFT holders
function invariant_followerCountAccurate() public {
uint256 reported = graph.followerCount(creator);
uint256 actual = followNFT.totalSupply();
assertEq(reported, actual);
}
// Content: every post must have valid content URI
function invariant_postsHaveContent() public {
for (uint i = 1; i <= registry.postCount(); i++) {
string memory uri = registry.contentURI(i);
assertTrue(bytes(uri).length > 0, "Post has no content URI");
}
}
// Monetization: total fees collected must equal sum of all transactions × fee rate
function invariant_feeAccounting() public {
assertEq(
monetization.totalFeesCollected(),
monetization.totalTransactionVolume() * monetization.feeRate() / 10000
);
}
// Reputation: score must be within valid bounds
function invariant_reputationBounds() public {
uint256 score = reputation.getScore(user);
assertGe(score, 0);
assertLe(score, reputation.MAX_SCORE());
}
// Copy trading: follower's PnL must proportionally match leader's PnL
function invariant_copyTradePnLProportional() public {
int256 leaderPnL = vault.leaderPnL();
int256 followerPnL = vault.followerPnL(follower);
uint256 followerShare = vault.shareOf(follower);
// Follower PnL should be proportional to their share
assertApproxEqRel(
followerPnL,
leaderPnL * int256(followerShare) / int256(vault.totalShares()),
0.01e18 // 1% tolerance for fees
);
}| Attack | Description | Mitigation |
|---|---|---|
| Bonding Curve Manipulation | Flash loan to pump price, sell at peak, dump curve | Buy/sell cooldowns, max transaction size |
| Wash Trading (Creator Tokens) | Self-trade to inflate volume and attract real buyers | Volume-weighted scoring, min hold periods |
| Sybil Follower Farming | Create many wallets to fake follower counts and earn rewards | Gitcoin Passport, min stake to follow, SBTs |
| Front-Running Collects | See collect tx, front-run to buy creator token before price rise | Bonding curve slippage protection, MEV protection |
| Content Spam / DoS | Flood the feed with garbage posts to drown real content | Posting stake, spam filter, reputation threshold |
| Moderation Capture | Malicious actors gain moderation power to censor competitors | Decentralized jury, rotating moderators, appeals |
| Rug Pull (Creator Token) | Creator sells all their tokens and abandons community | Vesting schedule, sell caps, gradual unlock |
| Replay Attack (Messages) | Replaying old messages to impersonate or confuse | Nonces, timestamps, XMTP's built-in protection |
| Oracle Manipulation (Reputation) | Gaming the reputation oracle to inflate score | Multi-source reputation, decay over time |
| Copy Trade Front-Running | Detecting leader's trade in mempool, front-running as follower | Private mempool, delayed execution, batch trades |
| Approval Phishing | Tricking users into approving token spend for creator tokens | Clear approval UX, limited approvals |
- Bonding curves have maximum buy/sell per transaction limits
- Creator tokens have sell cooldown to prevent pump-and-dump
- Reentrancy guards on all buy/sell/tip/collect functions
- Content posting requires minimum reputation or stake
- Sybil resistance via Gitcoin Passport or minimum balance
- Moderation actions are reversible via appeals process
- Copy trading vaults have maximum follower allocation limits
- Fee calculations checked for rounding exploits
- XMTP messages validated for sender authenticity
- Creator token reserves provably solvent at all times
- Emergency pause on bonding curve contracts
- Admin functions behind timelock or multi-sig
| Network | Chain ID | Why |
|---|---|---|
| Base | 8453 | friend.tech native, Farcaster ecosystem, low fees, consumer UX |
| Polygon | 137 | Lens Protocol native, low fees, established social ecosystem |
| Optimism | 10 | Farcaster Hubs, attestations, public goods ecosystem |
| Arbitrum | 42161 | Low fees, strong DeFi for social trading features |
| Ethereum | 1 | ENS, high-value creator tokens, maximum security |
| Zora Network | 7777777 | Content NFTs, Zora protocol for minting social posts |
| Sepolia | 11155111 | Testing |
# 1. Deploy Social Graph
forge script script/DeploySocialGraph.s.sol \
--rpc-url $BASE_RPC_URL --broadcast --verify
# 2. Deploy Creator Token Factory
forge script script/DeployCreatorTokenFactory.s.sol \
--rpc-url $BASE_RPC_URL --broadcast --verify
# 3. Deploy Content Registry
forge script script/DeployContentRegistry.s.sol \
--rpc-url $BASE_RPC_URL --broadcast --verify
# 4. Deploy Monetization Module
forge script script/DeployMonetization.s.sol \
--rpc-url $BASE_RPC_URL --broadcast --verify
# 5. Deploy Reputation System
forge script script/DeployReputation.s.sol \
--rpc-url $BASE_RPC_URL --broadcast --verify
# 6. Create a creator token
cast send $FACTORY "createToken(string,string)" "AliceToken" "ALICE" \
--rpc-url $BASE_RPC_URL --private-key $PRIVATE_KEY| Concept | Description |
|---|---|
| SocialFi | Social media + DeFi — users own content, monetize interactions, govern platforms |
| Social Graph | Network of follows/connections stored on-chain, portable across apps |
| Creator Token (Social Token) | Personal token representing a creator's social capital — price-driven by demand |
| Bonding Curve | Mathematical function determining token price based on supply |
| Keys / Shares | friend.tech model — buy shares of a person to access their gated community |
| Content NFT (Collect) | Turning a post/article into a mintable NFT edition — fans collect to support |
| Token Gating | Restricting access to content/communities based on token or NFT holdings |
| Portable Identity | Self-sovereign identity that works across all SocialFi apps |
| Soulbound Token (SBT) | Non-transferable token for reputation, achievements, credentials |
| Social Recovery | Recover account via trusted social connections instead of seed phrases |
| Reputation Score | On-chain score built from posting, engagement, and community participation |
| Copy Trading | Automatically mirroring another trader's on-chain transactions |
| Attention Economy | Model where user attention is tokenized and creators are paid for engagement |
| Decentralized Moderation | Community-governed content moderation via staking and voting |
| XMTP | Decentralized messaging protocol for wallet-to-wallet encrypted communication |
| Push Protocol | Decentralized notification and chat protocol for Web3 |
| Lens Protocol | Composable social graph on Polygon — profiles, posts, follows as NFTs |
| Farcaster | Sufficiently decentralized social protocol — Hubs + Frames + channels |
| Farcaster Frames | Interactive mini-apps embedded in Farcaster posts (like social widgets) |
| Mirror | Decentralized publishing platform — articles as NFTs on Arweave |
| Guild.xyz | Token-gating-as-a-service — gate Discord, Telegram, and web pages |
| Lit Protocol | Decentralized access control — encrypt/decrypt based on token ownership |
| Ceramic | Decentralized data network for mutable, user-controlled data streams |
A snapshot of key tokens powering the SocialFi ecosystem:
| Token | Project | Role in Ecosystem |
|---|---|---|
| DESO | DeSo (Decentralized Social) | Layer 1 blockchain purpose-built for social apps |
| LENS | Lens Protocol | Social graph protocol on Polygon — profiles, follows, collects |
| FID (Farcaster) | Farcaster | Decentralized social protocol — not a token but a valuable ID |
| CYBER | CyberConnect | Decentralized social graph, Link3 profiles, middleware |
| AUDIO | Audius | Decentralized music streaming — artists earn directly |
| BAT | Brave / Basic Attention | Attention token — users earn for viewing ads in Brave browser |
| MASK | Mask Network | Bridge Web2 social media (Twitter) to Web3 features |
| RSS3 | RSS3 | Open information layer — decentralized content indexing |
| GALXE | Galxe (formerly Project Galaxy) | Credential and campaign platform, community quests |
| GTC | Gitcoin | Gitcoin Passport (sybil resistance), public goods funding |
| PUSH | Push Protocol | Decentralized notifications and messaging for Web3 |
| STATUS | Status | Encrypted messaging, crypto wallet, and dApp browser |
| FRIEND | friend.tech | Social keys — buy shares of creators for gated chat access |
| ZORA | Zora | NFT minting protocol — turn social posts into collectibles |
- Lens Protocol Docs — Composable social graph on Polygon
- Farcaster Protocol — Sufficiently decentralized social
- CyberConnect Docs — Social graph middleware
- Neynar (Farcaster API) — Farcaster data and actions API
- Airstack — Cross-protocol social data queries
- XMTP Docs — Decentralized messaging protocol
- Push Protocol Docs — Notifications and chat for Web3
- Waku — Decentralized communication network
- Mirror — Decentralized publishing
- Lit Protocol Docs — Decentralized access control
- Guild.xyz Docs — Token gating as a service
- Zora Protocol Docs — Mint posts as collectible NFTs
- ENS Docs — Ethereum Name Service
- Gitcoin Passport — Sybil resistance and identity
- Ceramic Docs — Decentralized data streams
- EAS (Ethereum Attestation Service) — On-chain attestations
- Foundry Book
- OpenZeppelin Contracts
- wagmi Documentation
- The Graph — Indexing protocol
- Trail of Bits
- Slither — Static analysis
- Echidna — Fuzzing
Contributions are welcome! Whether it's a new social primitive, monetization model, or platform feature:
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-social-feature) - Follow the existing project structure
- Include comprehensive tests (unit + fuzz + invariant)
- Add a
README.mdwith architecture, economic model, and security analysis - Submit a pull request
High-impact contribution ideas:
- Farcaster Frame mini-app builder
- On-chain recommendation algorithm (transparent feed ranking)
- Decentralized content moderation with stake-based jury
- Cross-platform identity aggregator (Lens + Farcaster + ENS)
- Social token vesting with milestone-based unlocks
- Decentralized ads marketplace with privacy-preserving targeting
This repository is licensed under the MIT License.
Your content. Your followers. Your revenue. Build the social platforms where users are the product owners, not the product.