Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Guides

How to Implement a Reputation-Weighted Distribution

A technical guide for developers on designing and coding a token distribution system that allocates tokens based on a user's calculated reputation score within a community or protocol.
Chainscore © 2026
introduction
TUTORIAL

How to Implement a Reputation-Weighted Distribution

A step-by-step guide to designing and deploying a smart contract system that allocates tokens or rewards based on a user's on-chain reputation score.

A reputation-weighted distribution is a mechanism that allocates resources—like tokens, voting power, or access—based on a participant's proven contribution or trustworthiness within a system. Unlike simple token-weighted models, it aims to reward quality and long-term engagement. Common applications include distributing governance power in DAOs, allocating grants in ecosystems, and airdropping tokens to active protocol users. The core challenge is programmatically defining and calculating a reputation score from on-chain data, such as transaction history, staking duration, or contribution volume.

The implementation involves three key smart contract components. First, a Reputation Oracle calculates scores. This can be an off-chain service or an on-chain contract that processes historical data, perhaps using a formula like score = (total_volume * 0.5) + (time_locked * 0.3) + (governance_participation * 0.2). Second, a Reputation Registry stores and updates these scores in a mapping, such as mapping(address => uint256) public reputationScore. Third, the Distribution Contract uses these scores to allocate tokens proportionally, calculating a user's share as (userScore / totalReputation) * distributionPool.

Here is a simplified Solidity example for the distribution logic. The contract pulls a user's score from the registry and calculates their claimable amount.

solidity
interface IReputationRegistry {
    function getScore(address user) external view returns (uint256);
    function getTotalScore() external view returns (uint256);
}

contract RepWeightedDistributor {
    IReputationRegistry public registry;
    uint256 public totalToDistribute;

    function claimTokens() external {
        uint256 userScore = registry.getScore(msg.sender);
        uint256 totalScore = registry.getTotalScore();
        require(totalScore > 0, "No reputation scores");

        uint256 userShare = (userScore * totalToDistribute) / totalScore;
        // Transfer logic here
    }
}

This pattern ensures allocations are dynamic and automatically adjust as reputation scores change.

Critical design considerations include score sybil-resistance and data freshness. To prevent manipulation, base scores on non-transferable actions like providing liquidity, voting, or completing verified tasks. Use time-weighted metrics (e.g., staking for 6 months vs. 6 days) to favor commitment. The reputation oracle should periodically update scores in a merkle tree or via a secure oracle like Chainlink to keep data current without excessive gas costs. Avoid storing complex calculation logic on-chain; compute scores off-chain and submit proofs or signed messages.

For production systems, integrate with existing reputation primitives. Projects like Gitcoin Passport aggregate off-chain identity signals, while Orange Protocol and RabbitHole issue verifiable credentials for on-chain achievements. Your distribution contract can verify these credentials to determine eligibility and weight. When planning a distribution, clearly communicate the scoring formula and data snapshot block to users. Transparency builds trust and reduces disputes. Finally, consider adding a vesting schedule to the distributed tokens to align long-term incentives with the reputation model's goals.

prerequisites
PREREQUISITES AND CORE CONCEPTS

How to Implement a Reputation-Weighted Distribution

This guide explains the core mechanics of designing and deploying a token distribution system where allocations are determined by a participant's on-chain reputation.

A reputation-weighted distribution is a token allocation mechanism that moves beyond simple metrics like token holdings or snapshot voting. Instead, it calculates a user's reputation score based on their historical, verifiable on-chain activity. This score then determines their proportional share of a token airdrop, governance power, or access to a protocol's rewards. The goal is to align incentives with long-term, constructive participation rather than transient capital. Core prerequisites for implementation include a clear definition of "valuable actions," a method for querying and scoring on-chain data, and a secure distribution smart contract.

The first step is defining the reputation parameters. What on-chain actions contribute to a user's score? Common examples include: the volume and duration of liquidity provided in specific pools, consistent participation in governance proposals, completion of quests or contributions in a developer ecosystem, or holding non-transferable soulbound tokens (SBTs) from recognized communities. Each action is assigned a weight. For instance, providing $10,000 in liquidity for 90 days might yield a higher score than a single governance vote. The parameters must be transparent, objective, and resistant to sybil attacks—where a user creates multiple wallets to game the system.

Next, you need a reliable data source to calculate scores. You cannot rely on a centralized database; the system's legitimacy depends on verifiable, on-chain data. This typically involves using an indexer or subgraph (e.g., The Graph) to query historical blockchain events related to your defined actions. For Ethereum and EVM chains, you might query event logs from specific smart contract addresses. The scoring logic, often written in a script (Python/JavaScript) or within the indexer itself, processes this data to generate a final reputation score for each eligible address. This score is usually represented as a simple integer or a fixed-point number.

With scores calculated, the distribution logic is encoded into a smart contract. The contract must have a merkle root—a cryptographic commitment—of all eligible addresses and their calculated allocations stored on-chain. Users can then submit a merkle proof to claim their tokens. A critical security consideration is including a vesting or cliff period within the contract to prevent immediate dumping by recipients, which undermines the goal of fostering long-term alignment. Always audit this distribution contract thoroughly, as it will hold the tokens to be distributed.

Here is a simplified conceptual outline of a distribution contract function using a merkle proof, written in Solidity pseudocode:

solidity
function claimTokens(bytes32[] calldata merkleProof, uint256 allocatedAmount) external {
    bytes32 leaf = keccak256(abi.encodePacked(msg.sender, allocatedAmount));
    require(MerkleProof.verify(merkleProof, merkleRoot, leaf), "Invalid proof");
    require(!hasClaimed[msg.sender], "Already claimed");
    hasClaimed[msg.sender] = true;
    // Transfer logic with vesting checks would go here
    token.safeTransfer(msg.sender, allocatedAmount);
}

The merkleRoot is set by the deployer based on the pre-calculated reputation scores, and each user's allocatedAmount is their share of the total distribution pool.

Finally, consider the operational workflow: 1) Snapshot the chain state at a defined block height, 2) Run your scoring script against the indexed data to generate (address, score) pairs, 3) Normalize scores into token allocations, 4) Generate a merkle tree from the final allocation list, 5) Deploy the distribution contract with the merkle root and funded tokens, 6) Publish the merkle tree data (e.g., as a JSON file on IPFS) so users can generate their proofs. Tools like OpenZeppelin's MerkleProof library and frameworks like Hardhat or Foundry are essential for development and testing.

reputation-data-sources
IMPLEMENTATION GUIDE

Sourcing Reputation Data

Reputation-weighted distributions require robust, on-chain data sources. This guide covers the primary methods for sourcing and verifying reputation signals.

scoring-models
IMPLEMENTATION GUIDE

Designing the Reputation Scoring Model

This guide details the technical process of implementing a reputation-weighted distribution system, a core mechanism for aligning incentives and mitigating Sybil attacks in decentralized protocols.

A reputation-weighted distribution allocates rewards, voting power, or access based on a user's historical, on-chain contributions. Unlike simple token-weighted systems, it aims to measure quality of participation rather than just capital. This is critical for protocols like retroactive public goods funding (RPGF) or governance, where the goal is to reward genuine builders and engaged community members. The core challenge is designing a scoring model that is objective, transparent, and Sybil-resistant, using verifiable on-chain data as its foundation.

The first step is defining the data sources for your reputation score. Common sources include: - Transaction history: Volume, frequency, and recency of interactions with the target protocol. - Contribution artifacts: Deployed smart contracts, verified GitHub commits linked to an on-chain identity, or created governance proposals. - Social graph: Delegations received in governance or attestations from other reputable entities. Each data point should be publicly verifiable on-chain or through a decentralized identifier (DID) to ensure auditability and prevent manipulation.

Next, you must construct the scoring algorithm. A simple model could be a formula like: Score = (Activity_Score * w1) + (Tenure_Score * w2) + (Impact_Score * w3). Here, Activity_Score might count transactions, Tenure_Score measures time since first interaction, and Impact_Score quantifies the value of deployed contracts. Weights (w1, w2, w3) are set by governance to reflect protocol priorities. For Sybil resistance, consider mechanisms like quadratic weighting of sub-scores or context-specific decay that reduces the value of old, low-impact actions over time.

Implementing this model requires a verifiable off-chain computation or a gas-efficient on-chain contract. For complex calculations, a common pattern is to use an indexer (like The Graph) to compute scores off-chain and publish the results with cryptographic proofs (e.g., using Ethereum Attestation Service). For simpler models, a Solidity contract can compute scores on-demand, though gas costs must be considered. The final output is typically a mapping of addresses to scores, stored in a Merkle tree for efficient verification in distribution contracts.

Finally, integrate the score into your distribution mechanism. In a funding round, this could mean allocating tokens proportionally to the reputation score. In governance, it might translate to weighted voting. It's crucial to publish the full methodology and code for community audit. Projects like Gitcoin Passport and Optimism's AttestationStation provide frameworks for building and attesting to such reputation data. Always start with a simple, explainable model and iterate based on governance feedback and observed outcomes.

WEIGHTING STRATEGIES

Comparison of Distribution Weighting Models

A technical comparison of common algorithms for calculating reputation scores to weight token or reward distributions.

Model / MetricQuadratic FundingTime-Decay ReputationProof-of-ParticipationStake-Weighted

Core Mechanism

Square root of contributions

Exponential decay of past actions

Verifiable on-chain/off-chain tasks

Linear to token stake

Sybil Resistance

Capital Efficiency

High (amplifies small contributions)

Medium

High

Low

Implementation Complexity

Medium (requires zk-SNARKs for privacy)

Low

High (oracle/attestation needed)

Low

Typical Use Case

Public goods funding (Gitcoin)

Governance voting power

Retroactive airdrops, contributor rewards

Liquid staking, DeFi yield

Vulnerability to Whale Dominance

On-Chain Gas Cost per User

~500k-1M gas

~50k-100k gas

~200k-500k gas

~20k-50k gas

Requires External Oracle

contract-implementation
SMART CONTRACT PATTERN

How to Implement a Reputation-Weighted Distribution

A guide to building a Solidity contract that distributes tokens or rewards based on a user's on-chain reputation score.

A reputation-weighted distribution is a mechanism where the allocation of a resource (like tokens, voting power, or rewards) is proportional to a participant's accumulated reputation. This pattern is used in DAO governance, retroactive funding (like Optimism's Citizen House), and community airdrops to reward past contributions. The core contract logic involves storing a reputation score for each address and using it to calculate their share of a distribution. Unlike a simple linear distribution, this creates sybil-resistance and aligns incentives with proven, long-term engagement.

The implementation requires two key data structures: a mapping to store reputation scores and a mechanism to update them. A common approach is to use an ERC-20 style _balances mapping for scores, allowing for easy transfers or delegation if needed. Scores can be updated by a privileged role (e.g., a DAO multisig) or algorithmically based on on-chain actions. It's critical that the scoring logic is transparent and, if possible, permissionless to audit, as it forms the trust basis for the system.

solidity
mapping(address => uint256) public reputationScore;
address public distributor;

function updateReputation(address _user, uint256 _newScore) external {
    require(msg.sender == distributor, "Unauthorized");
    reputationScore[_user] = _newScore;
}

The distribution function calculates each user's share based on their score relative to the total reputation supply. You must iterate through a pre-approved list of recipients to calculate the sum of all scores, then calculate each user's proportion. For gas efficiency with large sets, consider using a Merkle tree for off-chain calculation and on-chain verification, or a pull-based claim mechanism where users claim their share after the total and their proof are set. Always guard against division-by-zero errors and integer overflow.

solidity
function distributeTokens(address[] calldata recipients, IERC20 token) external {
    uint256 totalRep;
    for (uint i = 0; i < recipients.length; i++) {
        totalRep += reputationScore[recipients[i]];
    }
    uint256 totalTokens = token.balanceOf(address(this));
    for (uint i = 0; i < recipients.length; i++) {
        uint256 share = (totalTokens * reputationScore[recipients[i]]) / totalRep;
        token.transfer(recipients[i], share);
    }
}

Key security considerations include ensuring the reputation update function is properly access-controlled, protecting against governance attacks where an actor could concentrate reputation to capture future distributions. For on-chain calculations, be mindful of gas limits when looping over large arrays; batch operations or a snapshotting pattern may be necessary. Always use the Checks-Effects-Interactions pattern and consider making the distribution function pausable in case of discovered vulnerabilities. The source of truth for reputation (on-chain vs. off-chain) significantly impacts the system's trust assumptions and upgradeability.

This pattern can be extended with features like vesting schedules (reputation unlocks rewards over time), decaying reputation (scores decrease over periods of inactivity to promote ongoing participation), and reputation delegation (allowing users to lend their voting weight). Projects like Optimism's AttestationStation or Ethereum's ERC-20 tokens themselves can serve as the underlying reputation ledger. By implementing this, you create a foundational primitive for building sophisticated, merit-based economic systems on-chain.

off-chain-calculator
IMPLEMENTATION GUIDE

Building the Off-Chain Score Calculator

This guide details the technical implementation of a reputation-weighted distribution system, a core component for fair airdrops and governance.

A reputation-weighted distribution algorithm allocates tokens or rewards based on a user's calculated off-chain score. This score is derived from on-chain activity, such as transaction volume, protocol interactions, and governance participation, but the calculation itself is performed off-chain for efficiency and cost savings. The primary goal is to move beyond simple Sybil-resistant checks like proof-of-humanity and instead reward genuine, high-quality engagement within an ecosystem. This system is essential for projects aiming to bootstrap a decentralized, aligned community rather than distributing tokens to passive wallets or farmers.

The implementation involves three core stages: data ingestion, score calculation, and merkle tree generation. First, you must index relevant on-chain data from sources like The Graph, Dune Analytics, or a custom indexer. Key metrics might include total value locked (TVL), number of transactions, duration of holding, participation in governance votes, or contributions to protocol development. This raw data is then normalized and fed into a scoring formula. A common approach is a linear weighted sum, where each activity type has a predefined weight (e.g., governance votes: 0.4, transaction count: 0.3, TVL: 0.3). The formula Score = ÎŁ (activity_i * weight_i) produces a final reputation score for each address.

To enable gas-efficient on-chain verification, the final list of eligible addresses and their calculated allocations must be committed to a Merkle root. Using a library like OpenZeppelin's MerkleProof, you generate a tree where each leaf is the hash of an address and its allocated token amount. The root of this tree is stored on-chain in the distribution contract. Users can then claim their tokens by submitting a Merkle proof that their address and allocation are part of the verified set. This pattern, used by protocols like Uniswap and Optimism, ensures the heavy computation stays off-chain while maintaining cryptographic integrity on-chain.

Here is a simplified Node.js example using merkletreejs and keccak256 to generate the tree and root from a list of scores:

javascript
const { MerkleTree } = require('merkletreejs');
const keccak256 = require('keccak256');

// Example data: address -> calculated allocation
const scores = [
  { address: '0x1234...', allocation: '1000000000000000000' },
  { address: '0xabcd...', allocation: '500000000000000000' }
];

// Create leaves: hash(address + allocation)
const leaves = scores.map(s => 
  keccak256(s.address + s.allocation)
);

const tree = new MerkleTree(leaves, keccak256, { sortPairs: true });
const root = tree.getHexRoot(); // To be stored on-chain
console.log('Merkle Root:', root);

The contract would then verify claims using MerkleProof.verify(proof, root, leaf).

Critical considerations for production include score decay to prioritize recent activity, anti-sybil clustering to identify and down-weight coordinated wallets, and transparent parameter selection. The weights and formula should be published, and ideally governed by the community. Furthermore, you must handle edge cases like contract addresses and ensure the data sources are reliable and resistant to manipulation. Regularly updating the score snapshot and Merkle root allows for dynamic reputation tracking over time, creating a living system that continuously aligns incentives with valuable user behavior.

tools-and-libraries
REPUTATION SYSTEMS

Tools and Libraries

Implementing a reputation-weighted distribution requires a stack of smart contracts, oracles, and data tools. These resources provide the foundational components.

06

Reputation Calculation Frameworks

Design your scoring model using frameworks for on-chain history analysis. While no single library exists, build using:

  • EVM Tracing Libraries (ethers.js, viem): Parse transaction histories to calculate metrics like total value bridged, consistent DEX usage, or governance participation.
  • POAP & Galxe: Use proof-of-attendance NFTs as a verifiable reputation signal.
  • Key Principle: Reputation should be transparent, composable, and context-specific. A score for a grant round might weight Gitcoin contributions, while a DeFi protocol might weight liquidity provision history.
1.7M+
POAP Holders
REPUTATION-WEIGHTED DISTRIBUTION

Frequently Asked Questions

Common technical questions and solutions for developers implementing reputation-weighted mechanisms for token airdrops, governance, or rewards.

A reputation-weighted distribution allocates tokens based on a user's on-chain reputation score, not just a simple metric like token balance or transaction count. It uses a multi-factor formula to calculate contributions, rewarding quality over quantity.

Key differences from a linear airdrop:

  • Linear: Distributes tokens proportionally to a single, easily sybil-attackable metric (e.g., ETH balance at a snapshot).
  • Reputation-Weighted: Uses a composite score from multiple on-chain actions (e.g., governance participation, long-term holding, providing liquidity, contributing code). The distribution is often non-linear, using a curve (like a square root) to prevent whale dominance.

For example, Gitcoin Passport uses attestations to score user humanity and contribution depth, influencing grant matching. This targets meritocratic distribution instead of wealth-based distribution.

conclusion
IMPLEMENTATION GUIDE

Conclusion and Next Steps

This guide has outlined the core components of a reputation-weighted distribution system. The final step is integrating these concepts into a functional application.

To implement the system, you must combine the on-chain and off-chain components. The smart contract handles the final distribution logic, but it relies on a trusted oracle or relayer to submit the calculated reputation scores. A common pattern is to have an off-chain indexer or server that calculates scores based on on-chain activity, signs the data, and submits it via a transaction to the distributeTokens function. This separation ensures the heavy computation of reputation (which may involve analyzing historical transactions) doesn't incur gas costs for every user.

For production deployment, security and upgradeability are critical. Consider using a multisig wallet or DAO as the contract owner to authorize new distribution rounds. Implement a timelock for critical functions like changing the reputation oracle address. Use established libraries like OpenZeppelin's for access control (Ownable or AccessControl) and consider making the distribution contract upgradeable using a proxy pattern (e.g., Transparent Proxy or UUPS) to allow for future improvements to the scoring algorithm without losing the contract's state or funds.

The next logical step is to explore advanced reputation mechanics. Instead of a simple formula, you could implement a time-decay factor where older contributions weigh less, or a peer prediction mechanism where users stake on each other's reputations. Integrating with zero-knowledge proofs (ZKPs) could allow users to prove they meet a reputation threshold without revealing their entire history, enhancing privacy. Frameworks like Semaphore or zkSNARKs libraries can be explored for this purpose.

To test and iterate your implementation, use a development framework like Foundry or Hardhat. Write comprehensive tests that simulate multiple distribution rounds, malicious oracle behavior, and edge cases in user activity. Deploy first to a testnet (like Sepolia or Goerli) and use a faucet for test ETH. Tools like Tenderly or OpenZeppelin Defender can help you monitor transactions and automate the off-chain reputation calculation and submission process.

Finally, analyze real-world data to calibrate your model. Use subgraphs from The Graph to query historical on-chain data from protocols your users interact with. The parameters in your scoring formula (like the weight for governance votes vs. liquidity provision) should be tuned based on the desired economic behavior. Launching with a community governance proposal to ratify the initial parameters can help ensure the system aligns with your project's goals and gains legitimacy from the start.