An on-chain social graph is a decentralized network mapping relationships and interactions between blockchain addresses. Unlike centralized platforms, it is user-owned, portable, and composable. Adding a reputation layer transforms this graph from a simple follower list into a dynamic system of trust and influence. Reputation is derived from verifiable on-chain actions—such as token holdings, governance participation, content creation, or successful transactions—creating a meritocratic social fabric. This guide outlines the core components and steps to launch such a system.
Launching a Reputation-Enabled Social Graph
Launching a Reputation-Enabled Social Graph
A technical guide to building a social graph where user interactions and contributions translate into on-chain reputation scores.
The architecture rests on three pillars: a graph data store, a reputation engine, and user-facing applications. The graph can be stored in a decentralized manner using protocols like Ceramic or The Graph, or managed off-chain with periodic state commitments to a blockchain like Ethereum or Polygon. The reputation engine is a set of smart contracts or off-chain indexers that apply predefined rules to on-chain activity, calculating scores. For example, a user's reputation might increase with each successful DAO vote or NFT collection they curate.
Start by defining your reputation logic. What actions matter? Common metrics include: token-weighted staking, proposal execution, content engagement (likes, mirrors), and peer attestations. Encode these rules in a Reputation Oracle smart contract. A simplified Solidity snippet for a staking-based score might look like:
solidityfunction calculateScore(address user) public view returns (uint256) { uint256 stake = IStaking(stakingContract).balanceOf(user); // Apply a square root to prevent whale dominance return sqrt(stake); }
This contract would be updated by indexers monitoring relevant chains.
Next, construct the social graph. When a user follows another address, sign a typed structured data message (EIP-712) and submit it to a Graph Manager contract. This creates a verifiable, on-chain attestation of the relationship. The contract can emit events that your indexing service uses to update the graph database. This ensures the social connections are as portable and sovereign as the reputation scores themselves, not locked into a single application.
Finally, integrate the graph and reputation into an application. Use a wallet like MetaMask or Rainbow for authentication via Sign-In with Ethereum. Query the graph and reputation scores to personalize feeds, prioritize content, or gate access to exclusive communities. For instance, only users with a Governance Reputation score above a certain threshold could create proposals in your app's forum. The entire system is transparent, allowing users to audit how their reputation is calculated and with whom they are connected.
Launching this stack requires careful consideration of gas costs, data indexing speed, and sybil resistance. Start on a low-cost L2 like Arbitrum or Base, use commit-reveal schemes for batch graph updates, and consider proof-of-personhood integrations like Worldcoin to mitigate fake accounts. By combining a portable social graph with programmable reputation, you build the foundation for the next generation of user-centric, trust-based web3 applications.
Prerequisites and Tech Stack
Building a reputation-enabled social graph requires a specific set of tools and foundational knowledge. This guide outlines the core technologies and concepts you need to understand before starting development.
A reputation-enabled social graph is a decentralized data structure that maps relationships between user identities (like Ethereum addresses) and attaches verifiable reputation scores to them. Unlike traditional social networks, this graph is typically built on-chain or using decentralized protocols like Ceramic or Lens Protocol. Reputation can be derived from on-chain activity—such as governance participation, DeFi interactions, or NFT holdings—and is often calculated using attestation frameworks like Ethereum Attestation Service (EAS) or Verax. Understanding these core components is the first prerequisite.
Your development stack will center on smart contract interaction and decentralized data storage. You should be proficient in a language like TypeScript or Python for building the application logic and indexers. Familiarity with Ethers.js v6 or Viem is essential for reading on-chain state and submitting transactions. For managing the graph data, you'll need to understand GraphQL for querying indexed data from services like The Graph or Goldsky, and potentially IPFS or Ceramic streams for storing profile metadata and attestations in a decentralized manner.
A local development environment is crucial. Set up Node.js (v18 or later) and use a package manager like npm or yarn. You will need access to an EVM-compatible blockchain for testing; we recommend using Foundry for smart contract development and Anvil for a local testnet, or Hardhat as an alternative framework. For interacting with reputation protocols, install the necessary SDKs, such as @ethereum-attestation-service/eas-sdk for EAS. Version control with Git and a basic understanding of Docker for containerized services (like a Graph node) will streamline your workflow.
Finally, grasp the key architectural patterns. Your application will likely follow a client-indexer model, where a frontend client queries an indexer that aggregates on-chain events into a readable graph. You must decide on a reputation scoring model—will it be a simple tally of attestations, a weighted formula, or a more complex algorithm? Defining this early influences your smart contract and indexing logic. For inspiration, study existing implementations like the Lens Protocol's social graph or Gitcoin Passport's aggregated stamp system to understand data modeling choices.
Step 1: Designing the On-Chain Data Model
The foundation of a reputation-enabled social graph is a well-structured data model. This step defines the core entities, their relationships, and how reputation is encoded on-chain.
An on-chain social graph maps relationships between user accounts, typically represented as Ethereum addresses or other blockchain identifiers. The core data model must define two primary entities: Nodes (users) and Edges (connections). A node stores a user's profile metadata, while an edge represents a unidirectional or bidirectional link, such as a "follow," "endorsement," or "trust" connection. This structure is inspired by graph databases but implemented within the constraints of smart contract storage.
Reputation is not a native property but an emergent property calculated from the graph's edge data. The model must therefore include attestations—signed, verifiable statements attached to edges. For example, an edge could store a uint256 score or a bytes32 attestation hash linking to an off-chain Verifiable Credential (like a W3C VC). Protocols like Ethereum Attestation Service (EAS) provide a standard schema for such on-chain attestations, which can be referenced by your graph's smart contracts.
When designing storage, consider gas efficiency and query patterns. A common approach uses mappings to store edges: mapping(address => mapping(address => Edge)) public edges. For reputation aggregation, you may need to store derived data, like a user's total incoming endorsement weight, in a separate mapping to avoid costly on-the-fly computations. Libraries like Solidity structs help organize edge data, which might include a score, timestamp, and attestationSchemaId.
The choice between storing data fully on-chain versus using hybrid storage is critical. Storing profile content (like bios) on-chain is expensive. A standard pattern is to store a content identifier (CID) on-chain, pointing to data stored on IPFS or Arweave. The graph contract then becomes a verifiable index of decentralized content, ensuring integrity while managing costs. This aligns with the Data Availability principles of modular blockchains.
Finally, the model must be extensible. Use upgradeable proxy patterns (like Transparent Proxy or UUPS) or design a schema registry that allows adding new attestation types without migrating the entire graph. Consider how Layer 2 solutions like Optimism or Base can reduce transaction costs for users creating edges, which is essential for network growth. The initial design decisions here will dictate the scalability and utility of your entire reputation system.
Step 2: Implementing the Reputation Algorithm
This guide details the implementation of a reputation scoring algorithm for a social graph, covering data ingestion, scoring logic, and on-chain anchoring.
A reputation algorithm transforms raw on-chain activity into a quantifiable trust score. For a social graph, this typically involves ingesting data from sources like Ethereum transaction histories, Lens Protocol or Farcaster interactions, and Gitcoin Passport attestations. The first step is to define a schema for these inputs, often using a graph database like The Graph for indexing or a custom indexer to query events such as token transfers, DAO votes, and social follows. This raw data forms the adjacency matrix and node attributes for your graph computation.
The scoring logic itself is a weighted sum of verifiable actions. Common reputation signals include: - Financial stake: Value locked in protocols or token holdings (weighted by time). - Social capital: Meaningful connections and endorsements within the graph (e.g., a follow from a high-reputation node carries more weight). - Governance participation: Proposals created or voted on in DAOs like Compound or Uniswap. - Content quality: Post engagement metrics (likes, mirrors) and anti-sybil proofs. An example formula in pseudocode might be: score = (0.4 * stake_score) + (0.3 * social_score) + (0.2 * gov_score) + (0.1 * content_score).
To make the reputation score usable and trustless, it must be verifiably anchored on-chain. This is often done by computing the score off-chain for efficiency, generating a Merkle proof of the calculation, and then posting the Merkle root to a smart contract on a scalable L2 like Arbitrum or Base. Users can then submit their proof to the contract to claim a Soulbound Token (SBT) representing their current reputation tier. This pattern, used by projects like Gitcoin Passport, ensures the score is tamper-proof and composable across different dApps without costly on-chain computation.
Implementing the algorithm requires careful parameter tuning and sybil resistance. Initial weights should be set based on community governance or historical analysis, with mechanisms for future upgrades. Incorporating EIP-712 signed attestations allows for portable, user-generated reputation claims. Furthermore, using zero-knowledge proofs (ZKPs) via frameworks like Circom can enable private reputation verification, where a user proves they have a score above a threshold without revealing the exact value or underlying data.
Finally, the system must be designed for continuous updates. Reputation decays over time to reflect current activity, requiring periodic re-calculation epochs (e.g., weekly). An event-driven architecture using Chainlink Automation or a keeper network can trigger these updates. The output is a dynamic, programmable reputation layer that developers can query via an API or smart contract to gate access to token-gated communities, weight governance votes, or personalize social feeds.
Step 3: Indexing and Querying with The Graph
Make your smart contract data accessible by deploying a subgraph that indexes on-chain interactions and enables powerful GraphQL queries.
A subgraph defines the data from your smart contracts that The Graph will index. You create a subgraph manifest (subgraph.yaml) which specifies the smart contract address, the blockchain network, the events to listen for, and how to map that event data to entities stored in The Graph's database. For a social graph, you would map events like ProfileCreated, ConnectionEstablished, or PostPublished to corresponding User, Connection, and Post entities. This mapping is written in a mapping script using AssemblyScript, a TypeScript-like language.
Once your subgraph definition is ready, you use the Graph CLI to generate code, build the project, and deploy it to a Graph Node. You can deploy to The Graph's decentralized network via the Graph Explorer or host your own node. The indexer will then begin scanning the blockchain from the defined start block, processing every relevant event, and executing your mapping handlers to populate and update the entity store. This creates a queryable GraphQL API endpoint specific to your subgraph.
The power of The Graph is unlocked through its GraphQL API. Instead of complex blockchain calls, applications query this indexed data with declarative GraphQL queries. For example, to fetch a user's profile and their connections, a query might look like:
graphqlquery GetUserWithConnections($id: ID!) { user(id: $id) { id handle bio connections { id toUser { handle } } } }
This returns structured JSON data, enabling efficient data fetching for frontend applications.
For a reputation-enabled system, your subgraph must index reputation-related state changes. This involves mapping events such as KarmaAwarded or EndorsementGiven to update a User entity's reputationScore or link to Endorsement entities. Complex logic, like calculating a score from multiple on-chain actions, should be performed in the mapping handler. The indexed reputation data becomes instantly queryable, allowing your app to sort users by reputation, filter content, or gate access based on a score.
Optimizing your subgraph is crucial for performance and cost. Use derived fields in your GraphQL schema to compute values on-demand instead of storing them. Implement pagination in your queries using first and skip arguments to handle large datasets. Carefully design entity relationships and indexes to avoid expensive full-table scans. Monitor your subgraph's syncing status and query performance using the Graph Explorer or your node's metrics to ensure low-latency data access for your application.
Step 4: Integrating Reputation into a dApp
This guide walks through the practical steps of building a reputation-enabled social graph, from designing the data model to querying on-chain interactions.
The core of a reputation-enabled social graph is a data model that maps relationships and scores. A common approach uses a directed graph where nodes represent user addresses and edges represent interactions like follows, likes, or token transfers. Each edge can be weighted by the interaction's value or frequency. For example, a Follow might have a base weight of 1, while a Token Transfer could be weighted by the ETH amount. This graph is typically stored off-chain in a database for efficient querying, with cryptographic proofs or on-chain events (like FollowNFT mints from Lens Protocol) serving as the source of truth.
To populate this graph, your dApp's backend must index on-chain and off-chain events. For on-chain data, use an indexer like The Graph to listen for events from relevant smart contracts (e.g., a social protocol's registry). For off-chain signals, your application server can emit signed messages for user actions, which are later verifiable. The indexing service processes these events, updates the graph database, and calculates reputation scores. A simple scoring algorithm could sum the weighted values of all inbound edges to a node, optionally applying time decay with a formula like score = sum(weight * e^(-λ * age)) where λ is a decay constant.
Expose the graph data through a GraphQL or REST API for your frontend. Key queries include fetching a user's connections (query UserConnections) and their reputation score. Implement real-time updates using WebSockets or GraphQL subscriptions to reflect new interactions instantly. For decentralization, consider storing the graph's state root on-chain periodically, allowing users to verify their reputation via Merkle proofs. This hybrid approach balances performance with verifiability.
In your dApp's frontend, integrate the reputation score to enhance user experience. Display scores next to profile names, use them to rank content in feeds, or gate certain actions (e.g., posting in a premium channel) behind a minimum score threshold. When a user initiates a new interaction, such as following another profile, the frontend should trigger the corresponding smart contract function or send a signed message to your backend API, which will then emit the event for indexing, closing the feedback loop.
For development, start with a testnet deployment of the social protocol (like Lens Protocol's Mumbai testnet) and a local Graph node. Use libraries like The Graph's CLI to create a subgraph definition that maps events to your schema. A sample subgraph manifest (subgraph.yaml) defines the data sources and handlers. Your backend service can be built with Node.js and a graph database like Neo4j or a simple PostgreSQL with a recursive query extension. Always include unit tests for your scoring logic and integration tests for the indexing pipeline.
Finally, plan for scalability and cost. As the graph grows, optimize queries with database indexes and consider partitioning. On-chain transaction costs for emitting events can add up; mitigate this by batching interactions or using layer-2 solutions. Regularly audit your scoring mechanism for sybil resistance and unintended biases. The completed system creates a dynamic, reputation-based layer that adds meaningful context to social interactions within your decentralized application.
On-Chain vs. Off-Chain Graph Computation
Key trade-offs between computing a social graph directly on a blockchain versus using off-chain infrastructure.
| Feature | On-Chain Computation | Hybrid Computation | Off-Chain Computation |
|---|---|---|---|
Data Availability & Provenance | Immutable, verifiable on-chain | Core attestations on-chain, computations off-chain | Depends on centralized or federated servers |
Computational Cost & Scalability | High gas fees, limited by block gas limits | Moderate on-chain costs, scalable off-chain processing | Low cost, horizontally scalable |
Graph Query Latency | Slow (block time + execution) | Fast for cached results, slower for new proofs | Very fast (< 100ms) |
Developer Experience & Flexibility | Limited to VM opcodes, complex for graph algorithms | Flexible off-chain logic with on-chain settlement | Maximum flexibility, no blockchain constraints |
Decentralization & Censorship Resistance | High (inherits L1/L2 security) | Medium (depends on prover/attestation network) | Low (controlled by server operators) |
Data Freshness Update Cost | High per-update transaction fee | Batched attestation updates, cost amortized | Negligible |
Example Protocols/Frameworks | The Graph (on-chain indexing) | EAS with off-chain resolvers, Hypercerts | Lens API, traditional databases |
Use Cases for Reputation-Enabled Graphs
Reputation graphs transform on-chain and social data into verifiable credentials for building smarter applications. These guides cover practical implementations.
Under-Collateralized Lending
Enable credit-based DeFi by using on-chain reputation as a substitute for excessive collateral. Lenders can assess borrower risk via a portable credit score built from transaction history.
- Key Metric: Analyze wallet history for consistent repayment, diversified asset holdings, and age.
- Protocol Example: Arcade.xyz uses NFT-based reputation for under-collateralized loans. A user's reputation graph could provide a more holistic score.
Curated Social Feeds & Discovery
Build social applications where content ranking and user discovery are driven by contextual reputation, not just follower counts. Prioritize signals from trusted peers within a specific community.
- Mechanism: In a developer DAO, weight a user's technical posts higher if they have high reputation from Gitcoin Grants or verified GitHub contributions.
- Tools: Integrate with Lens Protocol or Farcaster frames, using an external reputation oracle to score casts.
Reputation as a Transferable Asset
Implement systems where users can stake, delegate, or tokenize their reputation. This creates new economic models for influence and trust.
- Staking: Users stake reputation points to gain elevated access or voting power, with slashing for malicious acts.
- Soulbound Tokens (SBTs): Issue non-transferable SBTs representing reputation milestones, as conceptualized by Vitalik Buterin. These become permanent nodes in a user's graph.
Essential Resources and Tools
These resources help developers design, deploy, and maintain a reputation-enabled social graph using production-grade Web3 infrastructure. Each tool addresses a core layer: identity, social data, attestations, and sybil resistance.
Frequently Asked Questions
Common technical questions and troubleshooting for building on a reputation-enabled social graph.
A reputation-enabled social graph is a decentralized network mapping relationships (edges) between entities (nodes) where each node carries a verifiable, portable reputation score. Unlike traditional social graphs (e.g., Twitter's follower graph), reputation is not just a platform-specific metric like 'likes'. It is a composite score derived from on-chain and off-chain attestations, such as transaction history, governance participation, or peer endorsements. This reputation is stored in a decentralized identity (DID) standard like Verifiable Credentials and can be queried by smart contracts. The key difference is sovereignty and interoperability: a user's reputation is owned by them and can be used across multiple dApps without platform lock-in, enabling applications like undercollateralized lending based on social trust or sybil-resistant governance.
Conclusion and Next Steps
This guide has outlined the core components for building a reputation-enabled social graph. The final step is integrating these elements into a functional application.
To launch your social graph, begin by deploying the smart contracts for your AttestationStation and ReputationModule. Use a framework like Foundry or Hardhat for development and testing. Ensure your contracts implement the IAttestationStation interface for compatibility with the EAS SDK. After deployment, verify the contracts on a block explorer like Etherscan to establish trust with your users.
Next, integrate the frontend using the EAS SDK to allow users to create and query attestations. A typical flow involves connecting a user's wallet, prompting them to sign a transaction to make an attestation (e.g., vouching for a connection's skill), and then displaying the resulting attestation UID. Use GraphQL to query the subgraph for aggregated reputation scores and social connections, displaying this data in user profiles.
For ongoing development, consider these advanced features: implementing token-gated attestations to restrict who can vouch for certain traits, adding off-chain attestations via EAS for gasless interactions, or creating a governance mechanism where reputation scores influence voting power. Monitor on-chain activity with your subgraph to generate insights into network growth and engagement metrics.
The primary resources for your build are the official Ethereum Attestation Service documentation, the Graph Protocol documentation for subgraph development, and the viem or ethers.js libraries for wallet interaction. Joining developer communities like the EAS Discord or The Graph Discord is invaluable for troubleshooting and staying updated on best practices.
A successfully launched reputation graph creates a verifiable layer of social context on-chain. This foundation enables new applications in decentralized hiring, curated content feeds, trust-minimized lending, and community governance. Start with a minimal viable product focused on a single use case, gather user feedback, and iterate based on the on-chain reputation data your application generates.