We design and develop decentralized social networks — from integration with Lens Protocol to fully custom protocols. Every project is built on an on-chain social graph, ensuring identity portability and data ownership. An error at the architecture selection stage can inflate the budget by 30-50%, so we start with an in-depth requirements analysis. For example, for one project we chose Lens Protocol, which allowed us to launch an MVP in 7 weeks instead of 4 months of custom development, saving approximately 40% in development time. Our team has extensive experience in Lens Protocol development and Farcaster integration.
Choosing the architecture for a decentralized social network
The protocol choice is dictated by the trade-off between performance and decentralization.
- Lens Protocol (Polygon) — everything on‑chain: posts, likes, subscriptions. Every action is a transaction. Gas is paid either by the user or sponsored via ERC‑4337. Ideal for maximum interoperability and portable identity. Downside: latency and gas on L2. Throughput: Lens Protocol handles up to 1000 actions per second on Polygon, which is 5 times more than a typical custom protocol on Ethereum L1.
- Farcaster — identity on Ethereum, content on Hubs (federated servers). Fast, no gas for operations, but Hubs could theoretically filter messages.
- Custom protocol — full control, but more time for audit and development. Scaling requires own rollup solutions.
Our experience: for startups with standard functionality (feed, subscriptions, collect), Lens Protocol is optimal — quick launch in 6–10 weeks with ready infrastructure. If full independence from third-party protocols or specific moderation is needed, we build our own contracts. Using a ready protocol saves 30 to 50 percent of the smart contract development budget. Custom protocol development costs 3-4 times more than using Lens Protocol. As noted in the Lens Protocol specification, gas sponsoring is available via ERC-4337, which is critical for UX.
Implementing Lens Protocol integration
import { LensClient, development, production } from "@lens-protocol/client";
const lensClient = new LensClient({
environment: production,
});
// Fetch a profile
const profile = await lensClient.profile.fetch({
forHandle: "lens/stani",
});
// Publish a post
async function createPost(
profileId: string,
content: string,
imageUrl?: string
): Promise<string> {
const metadata = {
$schema: "https://json-schemas.lens.dev/publications/text-only/3.0.0/schema.json",
lens: {
id: uuidv4(),
content,
locale: "en",
mainContentFocus: "TEXT_ONLY",
tags: [],
},
};
const metadataURI = await uploadToIPFS(metadata);
const result = await lensClient.publication.postOnchain({
contentURI: metadataURI,
});
return result.id;
}
Collect mechanics (monetization):
const postWithCollect = await lensClient.publication.postOnchain({
contentURI: metadataURI,
openActionModules: [
{
collectOpenAction: {
simpleCollectOpenAction: {
amount: {
currency: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", // WMATIC
value: "1",
},
recipient: creatorAddress,
referralFee: 5, // 5% referral fee
followerOnly: true,
},
},
},
],
});
Lens supports sponsoring via ERC‑4337 — users don't pay MATIC. We configure this during integration.
How do we ensure security of smart contracts?
Security is paramount. We perform thorough audits using Slither, Mythril, and Echidna fuzzing on all social network smart contracts. An error in the identity contract can lock all accounts, so we rigorously test and review code. Never deploy custom contracts without an audit.
Creating a custom protocol: smart contracts
If full independence is required, we design our own contracts. Below are examples of key components with a gas optimization priority. We design custom social network protocols with audited smart contracts.
Identity
contract SocialIdentity is ERC721 {
struct Profile {
string handle;
string metadataURI;
uint256 followerCount;
uint256 followingCount;
uint256 publicationCount;
}
mapping(string => uint256) public handleToTokenId;
mapping(uint256 => Profile) public profiles;
function createProfile(string calldata handle, string calldata metadataURI)
external returns (uint256 tokenId)
{
require(handleToTokenId[handle] == 0, "Handle taken");
require(bytes(handle).length >= 3 && bytes(handle).length <= 31, "Invalid handle length");
tokenId = ++_tokenCounter;
_mint(msg.sender, tokenId);
profiles[tokenId] = Profile({
handle: handle,
metadataURI: metadataURI,
followerCount: 0,
followingCount: 0,
publicationCount: 0,
});
handleToTokenId[handle] = tokenId;
emit ProfileCreated(tokenId, handle, msg.sender);
}
}
Publications
contract Publications {
enum PublicationType { POST, COMMENT, REPOST }
struct Publication {
uint256 profileId;
string contentURI;
PublicationType pubType;
uint256 parentId;
uint256 timestamp;
uint256 collectCount;
uint256 commentCount;
uint256 mirrorCount;
}
mapping(uint256 => Publication) public publications;
function post(uint256 profileId, string calldata contentURI)
external returns (uint256 pubId)
{
require(socialIdentity.ownerOf(profileId) == msg.sender, "Not profile owner");
pubId = ++_publicationCounter;
publications[pubId] = Publication({
profileId: profileId,
contentURI: contentURI,
pubType: PublicationType.POST,
parentId: 0,
timestamp: block.timestamp,
collectCount: 0,
commentCount: 0,
mirrorCount: 0,
});
socialIdentity.incrementPublicationCount(profileId);
emit Posted(pubId, profileId, contentURI);
}
}
The social graph (Follows) is implemented as a separate contract with an NFT for each follow, ensuring unique relationships. NFT profile creation and management are handled seamlessly. This custom social network protocol gives full control over data and monetization.
Content and storage
Publications are stored as JSON metadata on IPFS — each post has its own CID. For mutable data (profile, settings) we use Ceramic/ComposeDB — a decentralized database on top of IPFS. Event indexing is done by TheGraph, providing fast queries to the feed.
Architecture comparison
| Parameter | Lens Protocol | Farcaster | Custom protocol |
|---|---|---|---|
| Decentralization | High | Medium (Hubs) | Full |
| Gas for user | Yes (can be sponsored) | No | Yes |
| Throughput | ~1000 tx/s | High (off-chain) | Depends on L2 |
| Development complexity | Medium | Low | High |
| Time to launch | 6–10 weeks | 4–8 weeks | 4–6 months |
| Development cost | $30,000 – $50,000 | $25,000 – $40,000 | $100,000+ |
Development stages
- Requirements analysis and architecture selection (1–2 weeks).
- Smart contract design or choosing a ready protocol.
- Contract development (identity, publications, social graph) for custom approach.
- Frontend integration with blockchain via wagmi + viem.
- Indexer (TheGraph) and storage (IPFS, Ceramic) setup.
- Testing (unit, integration, security audit).
- Mainnet deployment and support.
Importance of auditing custom contracts
A custom protocol is 100% custom code. An error in the identity contract can lock all accounts, and a vulnerability in the social graph can lead to loss of followers. We perform social network contract audit using Slither, Mythril, and Echidna fuzzing. Launching to mainnet without an audit is unacceptable.
Moderation and monetization
Moderation is based on the label, not delete principle: content is not removed from the protocol but flagged (Bluesky Labeler approach). Applications decide which content to display. Communities can implement DAO voting to remove from indexes.
Monetization for creators includes:
- Collect fees — readers pay for a copy of the post (each transaction costs ~0.001 MATIC on Polygon).
- Subscription NFT — monthly pass to premium content.
- Tipping — micropayments via L2.
- Token gating — access only for holders of a specified NFT.
- Ad revenue — the protocol distributes revenue among authors proportionally to views. Content monetization via NFT is a key feature, enabling creators to earn from their work.
What is included in the work? (deliverables)
The deliverable package includes: full documentation, access to repositories, team training, and one month of post-deployment support.
- Smart contracts (Identity, Publications, SocialGraph) with full documentation.
- Frontend on Next.js + wagmi + viem.
- Indexer and API for feed and search.
- Storage on IPFS and Ceramic.
- Unit and integration tests, audit report.
- Deployment and maintenance instructions.
- Client team training on protocol usage.
- One month of post-deployment support.
Timelines and cost
Timelines vary by complexity: basic Lens Protocol integration takes 6–10 weeks (cost $30,000–$50,000), custom protocol takes 4–6 months plus mandatory security audit (cost from $100,000). Exact cost is evaluated after a brief. We have delivered dozens of Web3 projects, guarantee audit, and provide post-launch support. Build your Web3 social network with our expertise. Contact us to discuss your project details.







