Repository navigation
Reputation System
- Introduction
- Project Structure
- Core Components
- Architecture Overview
- Detailed Component Analysis
- Dependency Analysis
- Performance Considerations
- Troubleshooting Guide
- Conclusion
This document explains Sigvara’s reputation system: how six factors are measured, normalized, and committed on-chain; how evidence is verified through a Merkle tree; how disputes are challenged; and how maturity, decay, and anti-sybil controls prevent farm-and-cash-out attacks. It is intended for both implementers and consumers who need to understand what a score means, how it is computed, and how to validate or gate on it.
The system separates computation from storage: the oracle network computes scores off-chain and proposes them to SigvaraReputation, which stores finalized scores, pending proposals, evidence roots, and maturity state. Consumers read spendable scores via getTotalScore or threshold checks via meetsThreshold.
Section sources
At a high level, the reputation system spans documentation, Solidity contracts, an Oracle service, and an SDK used by consumers:
- Documentation defines the model, architecture, and payment-backed attestation rules.
- The Solidity contract stores scores, pending proposals, evidence roots, and maturity.
- The Oracle service reads chain data, normalizes external feedback, computes scores, builds Merkle proofs, and proposes results.
- The SDK provides challenge-response utilities for authentication flows that may gate access based on reputation.
graph TB
subgraph "Documentation"
RM["Reputation Model"]
ARCH["Architecture"]
PAYDOC["Payment-Backed Attestations"]
end
subgraph "On-chain"
REP["SigvaraReputation.sol"]
end
subgraph "Oracle Service"
IDX["index.js"]
SCOR["scoring.js"]
PMT["payments.js"]
EXT["external.js"]
MRK["merkle.js"]
end
subgraph "SDK"
CHAL["challenge.ts"]
end
RM --> REP
ARCH --> REP
PAYDOC --> PMT
ARCH --> IDX
IDX --> SCOR
IDX --> PMT
IDX --> EXT
IDX --> MRK
REP --> CHAL
Diagram sources
- reputation-model.md:1-4
- architecture.md:10-40
- payment-backed-attestations.md:1-20
- SigvaraReputation.sol:22-78
- index.js:1-22
- scoring.js:1-8
- merkle.js:1-17
- challenge.ts:1-10
Section sources
- reputation-model.md:1-4
- architecture.md:10-40
- payment-backed-attestations.md:1-20
- SigvaraReputation.sol:22-78
- index.js:1-22
Sigvara’s reputation is a deterministic 0–100 score composed of six factors:
| Factor | Max Points | Purpose | Key Inputs | Anti-abuse Controls |
|---|---|---|---|---|
| Fee Activity | 20 | Measures real economic activity settled to the agent | Decayed volume of accepted payments | Decay half-life, per-payer cap, self-payment refusal |
| Success Rate | 15 | Outcome reported by payers | Age-weighted successful vs total attestations | Pseudo-observations (+5) prevent stale perfect ratios |
| Tenure | 30 | Span of verified paid activity faded by recency | First and last verified payment timestamps | Starts at first activity, not registration; recency fades abandoned history |
| External Trust | 25 | Normalized ERC-8004 feedback for a linked agent | Recognized rating tags from ERC-8004 registry | Ownership verification; only recognized tags; CounterAudit excluded |
| Community Standing | 5 | Deducted for unresolved flags | Flag count | Linear penalty capped at zero |
| Propagation | 5 | Inherited trust from counterparties’ external standing | Distinct counterparties with non-zero external score | Uses matured external score; damps reflexivity |
A newly registered agent starts with no score and cannot be scored until bonded. Only bonded agents are scorable; un-bonded agents remain PendingBond and are rejected by proposal logic.
Section sources
Signals flow into the oracle from multiple sources and are normalized into a single score:
sequenceDiagram
participant Client as "Client / Platform"
participant Oracle as "Oracle index.js"
participant Payments as "payments.js"
participant External as "external.js"
participant Scoring as "scoring.js"
participant Merkle as "merkle.js"
participant Contract as "SigvaraReputation.sol"
Client->>Oracle : Submit attestation with payment txHash
Oracle->>Payments : verifyPayment(txHash, agentAddress)
Payments-->>Oracle : {payer, amount, settledAt}
Oracle->>External : Read ERC-8004 feedback (if linked)
External-->>Oracle : externalScore
Oracle->>Scoring : computeScore(measured inputs)
Scoring-->>Oracle : {feeScore, successScore, ageScore, externalScore, communityScore, propagationScore}
Oracle->>Merkle : buildTree(payment events)
Merkle-->>Oracle : {root, leaves}
Oracle->>Contract : proposeReputation(didHash, data, evidenceRoot)
Contract-->>Oracle : ScoreProposed event
Note over Contract : Challenge window opens
Contract-->>Client : meetsThreshold / getTotalScore
Diagram sources
- index.js:170-199
- payments.js:142-238
- external.js:163-168
- scoring.js:128-153
- merkle.js:117-131
- SigvaraReputation.sol:326-386
Section sources
Fee activity measures settled volume rather than request counts. When payment verification is required, the oracle verifies each settlement transaction against the chain, extracts the payer from transfer logs, and accumulates age-weighted volume. Volume decays using a half-life; default settings imply one point per unit of volume, capped at 20 points. A per-payer cap prevents a small ring of wallets from substituting for a diverse customer base. Self-payments are refused to raise the cost of fake activity.
Key behaviors:
- Decayed volume uses
0.5^(age/half-life)weighting. - Per-payer cap limits contribution regardless of total amount sent.
- Trust multiplier can raise caps for counterparties with external standing.
- If verification is off, fee activity falls back to an attestation-count proxy, which is intentionally weaker.
flowchart TD
Start(["Start fee activity"]) --> Verify["Verify payment txHash on chain"]
Verify --> Valid{"Valid transfer<br/>to agent?"}
Valid --> |No| Reject["Reject attestation"]
Valid --> |Yes| Extract["Extract payer, amount, settledAt"]
Extract --> SelfCheck{"Self-payment?"}
SelfCheck --> |Yes| Reject
SelfCheck --> |No| Group["Group by payer with decay weights"]
Group --> Cap["Apply per-payer cap<br/>and trust multiplier"]
Cap --> Sum["Sum capped volumes"]
Sum --> Points["Convert volume to points<br/>capped at 20"]
Points --> End(["Return feeScore"])
Diagram sources
Section sources
- reputation-model.md:21-49
- payment-backed-attestations.md:24-71
- payment-backed-attestations.md:118-154
- payment-backed-attestations.md:156-175
- payments.js:142-238
- payments.js:336-355
- payments.js:419-447
- payments.js:504-508
Success rate is derived from outcomes reported by payers. It divides successful weight by total weight plus pseudo-observations to avoid a single lucky job outscoring a long record and to ensure stale records fade. Both numerator and denominator decay together so a ratio alone does not preserve old success forever.
Key behaviors:
- Pseudo-observations stabilize low-volume ratios.
- Decayed weights pull the score toward zero as evidence ages.
- Negative outcomes require admin-controlled reporting; positive outcomes carry payment cost.
flowchart TD
S(["Start success rate"]) --> Collect["Collect outcome-bearing attestations"]
Collect --> Weight["Apply decay weights"]
Weight --> Ratio["Compute successful / (total + prior)"]
Ratio --> Scale["Scale to 15-point max"]
Scale --> Clamp["Floor result"]
Clamp --> R(["Return successScore"])
Diagram sources
Section sources
Tenure measures the span between an agent’s first and most recent verified payment, multiplied by recency. It deliberately does not measure time since registration because waiting is free and trading is not. An agent with no verified payments scores zero tenure regardless of registration age. Abandoned activity fades quickly.
Key behaviors:
- Logarithmic curve over span days.
- Recency factor scales down abandoned history.
- Activity window excludes self-payments.
flowchart TD
T(["Start tenure"]) --> Window["Compute activity window<br/>firstActivitySec, lastActivitySec, recency"]
Window --> HasData{"Has first and last activity?"}
HasData --> |No| Zero["Return 0"]
HasData --> |Yes| Span["spanDays = (last - first) / 86400"]
Span --> Curve["ageCurve(spanDays)"]
Curve --> Apply["floor(curve × recency)"]
Apply --> Cap["Cap at 30"]
Cap --> TEnd(["Return ageScore"])
Diagram sources
Section sources
External trust carries ERC-8004 cross-protocol feedback normalized into a 0–25 score. The oracle verifies that the ERC-8004 identity NFT is owned by the same wallet as the Sigvara operator, then reads recognized rating tags and averages them before scaling to 25 points. CounterAudit feedback is excluded to avoid double counting.
Key behaviors:
- Ownership verification ties external reputation to the operator.
- Only recognized tags are normalized; bespoke scales are ignored.
- Fail-safe returns zero if configuration is missing or ownership fails.
flowchart TD
E(["Start external trust"]) --> Enabled{"External feed configured?"}
Enabled --> |No| ZeroE["Return 0"]
Enabled --> |Yes| VerifyOwner["Verify ERC-8004 NFT owner == operator"]
VerifyOwner --> OwnerOK{"Owner matches?"}
OwnerOK --> |No| ZeroE
OwnerOK --> |Yes| ReadFeedback["Read clients and feedback rows"]
ReadFeedback --> Normalize["Normalize recognized tags to 0..1"]
Normalize --> Mean["Mean of recognized ratings"]
Mean --> ScaleE["Scale to 25"]
ScaleE --> EEnd(["Return externalScore"])
Diagram sources
Section sources
Community standing starts at the maximum and deducts points for unresolved flags. Flags are reputational, distinct from slashing. The formula floors the penalty so fractional flag weights do not prematurely forgive bad behavior.
Key behaviors:
- Linear deduction:
max(0, 5 − flags × 2). - Floor applied to handle fractional decayed flags.
Section sources
Propagation awards up to 5 points based on the breadth of counterparties that have external standing. Each counterparty counts once regardless of payment size. The factor uses matured external scores to damp reflexivity and prevent bootstrapping from fresh identities.
Key behaviors:
- One point per fully trusted counterparty, pro-rated by external score.
- Uses matured external score to lag recent gains.
- Unknown counterparties read as zero.
flowchart TD
P(["Start propagation"]) --> Seen["Iterate distinct counterparties"]
Seen --> AddTrust["Add externalScore / MAX_EXTERNAL_SCORE"]
AddTrust --> CapP["Cap at 5"]
CapP --> PEnd(["Return propagationScore"])
Diagram sources
Section sources
Evidence enters through two paths:
- Pushed attestations: Clients submit a settlement transaction hash; the oracle verifies the transfer and takes the payer from the chain log.
- Pulled payments: Operators scan chain Transfer logs for credited payments; these carry no outcome and are excluded from the success ratio.
Normalization steps include:
- Verifying minimum amount and confirmations.
- Refusing self-payments.
- Recording settlement timestamp from block data.
- Applying decay weights.
- Capping per-payer contributions.
- Building Merkle roots over evidence leaves.
flowchart TD
In(["Evidence intake"]) --> Path{"Path type"}
Path --> |Attestation| Push["verifyPayment(txHash)"]
Path --> |Scan| Pull["Scan Transfer logs"]
Push --> Normalize["Normalize: payer, amount, settledAt"]
Pull --> Normalize
Normalize --> Decay["Apply decay weights"]
Decay --> Cap["Per-payer caps"]
Cap --> Merkle["Build Merkle root"]
Merkle --> Commit["Commit root on-chain"]
Diagram sources
- payment-backed-attestations.md:24-71
- payment-backed-attestations.md:118-154
- merkle.js:78-101
- merkle.js:117-131
Section sources
- payment-backed-attestations.md:24-71
- payment-backed-attestations.md:118-154
- merkle.js:78-101
- merkle.js:117-131
Each proposal commits a Merkle root over the evidence set. Leaves encode:
- Transaction hash
- Payer address
- Amount
- Settlement time in seconds
- Outcome code: failed, succeeded, or not reported
The tree uses sorted-pair hashing compatible with OpenZeppelin’s MerkleProof. Odd nodes are promoted rather than duplicated to prevent malleability. Verifiers rebuild leaves from chain data and check membership against the on-chain root.
classDiagram
class MerkleModule {
+leafFor(event) bytes32
+buildTree(events) Object
+rootFor(events) bytes32
+proofFor(tree, index) bytes32[]
+verifyProof(leaf, proof, root) bool
+hashPair(a, b) bytes32
+settledSeconds(event) number
+outcomeCode(success) uint8
}
class LeafEncoding {
+txHash : bytes32
+payer : address
+amount : uint256
+settledAt : uint256
+outcome : uint8
}
MerkleModule --> LeafEncoding : "encodes"
Diagram sources
Section sources
The challenge mechanism has two layers:
- On-chain proposal and rejection: Oracles propose scores; a slashing committee can reject proposals during the challenge window. Finalization is permissionless after the window closes.
- Operator divergence: A checker recomputes scores independently and records disagreements without overwriting live proposals. A watcher escalates divergences before the challenge window expires.
Additionally, the SDK provides challenge-response authentication for consumers gating access based on reputation. Challenges bind a DID, audience, nonce, and timestamp; responses are Ed25519 signatures over the payload.
sequenceDiagram
participant Primary as "Primary Oracle"
participant Checker as "Checker Operator"
participant Watcher as "Watcher"
participant Contract as "SigvaraReputation.sol"
participant Consumer as "Consumer App"
Primary->>Contract : proposeReputation(didHash, data, evidenceRoot)
Contract-->>Primary : ScoreProposed event
Note over Contract : Challenge window open
Checker->>Contract : proposeIfEmpty(didHash, data, evidenceRoot)
Contract-->>Checker : ScoreProposed event
Watcher->>Contract : Check proposal still live
Contract-->>Watcher : Pending score status
Watcher->>Contract : rejectReputation(didHash)
Contract-->>Watcher : ScoreRejected event
Consumer->>Contract : meetsThreshold(didHash, threshold)
Contract-->>Consumer : boolean
Diagram sources
- SigvaraReputation.sol:326-386
- SigvaraReputation.sol:392-450
- architecture.md:92-125
- challenge.ts:43-87
Section sources
- SigvaraReputation.sol:326-386
- SigvaraReputation.sol:392-450
- architecture.md:92-125
- challenge.ts:43-87
Maturity prevents farm-and-cash-out by releasing earned scores gradually. The contract stores an anchor matured score and a timestamp; reads extrapolate growth at a configurable rate per day. Falls apply immediately; rises are bounded. Operator transfers restart maturity to prevent buying aged identities.
Decay applies to:
- Payment volume for fee activity.
- Attestation weights for success rate.
- Tenure recency.
flowchart TD
M(["Start maturity calculation"]) --> Earned["Get earned score"]
Earned --> Anchor["Get matured anchor and timestamp"]
Anchor --> Compare{"Earned <= Anchor?"}
Compare --> |Yes| ReturnEarned["Return earned"]
Compare --> |No| TimeSince["Calculate time since anchor"]
TimeSince --> Release["released = anchor + (time × ratePerDay / 1 day)"]
Release --> CapM["Cap at earned"]
CapM --> ReturnM["Return released"]
Diagram sources
Section sources
Anti-sybil controls target farm-and-cash-out and wash-trading:
- Bond requirement: Only bonded agents are scorable; registration alone does not activate scoring.
- Per-payer caps: Prevent a small ring from substituting for diverse counterparties.
- Self-payment refusal: Raises the floor for fake activity.
- Decay: Makes farmed volume perishable unless renewed.
- Maturity: Limits how fast trust can be acquired and spent.
- Propagation damping: Uses matured external score to prevent reflexivity and bootstrapping.
- Slash resets: Slashing zeroes all factors and sets terminal status.
flowchart TD
A(["Attack vector"]) --> Control{"Control"}
A --> |Farm volume| Decay["Decay half-life"]
A --> |Wash trade| PerPayer["Per-payer cap"]
A --> |Self-pay| SelfRefuse["Self-payment refusal"]
A --> |Quick cashout| Maturity["Maturity release rate"]
A --> |Sybil ring| PropagationDamp["Propagation uses external score"]
A --> |Buy aged ID| TransferRestart["Transfer restarts maturity"]
Decay --> Safe["Reduced exploitability"]
PerPayer --> Safe
SelfRefuse --> Safe
Maturity --> Safe
PropagationDamp --> Safe
TransferRestart --> Safe
Diagram sources
- payment-backed-attestations.md:156-175
- reputation-model.md:222-257
- reputation-model.md:258-315
- payments.js:368-372
Section sources
- payment-backed-attestations.md:156-175
- reputation-model.md:222-257
- reputation-model.md:258-315
- payments.js:368-372
Assume:
- Accepted asset: USDC
-
PAYMENT_FEE_UNIT: 100 USDC per point - Default half-life: 90 days
- Per-payer cap: 4 points
Scenario:
- Four distinct payers each settle 500 USDC within the current epoch.
- Decayed volume sums to 2,000 USDC.
- Points = min(20, 2000 / 100) = 20.
If one payer sends 2,000 USDC alone:
- Capped contribution = 4 points.
- Total feeScore = 4.
Section sources
- reputation-model.md:21-49
- payment-backed-attestations.md:156-175
- payments.js:419-447
- payments.js:504-508
Assume:
- Pseudo-observations: 5
- Decayed successful weight: 8
- Decayed total weight: 10
Computation:
- Ratio = 8 / (10 + 5) = 0.533...
- Score = floor(0.533... × 15) = 8.
As evidence ages, both numerator and denominator decay, pulling the score toward zero unless new evidence accumulates.
Section sources
Assume:
- First verified payment: 730 days ago
- Last verified payment: today
- Recency: 1.0
Computation:
- Span days = 730
- ageCurve(730) = floor(log₂(730 + 1) × 3) ≈ 28
- ageScore = floor(28 × 1.0) = 28.
If last payment was 365 days ago:
- Recency < 1.0
- Score drops proportionally.
Section sources
Assume:
- Recognized tags: quality=80/100, reliability=4/5, win-rate=0.8
- Normalized values: 0.8, 0.8, 0.8
- Mean = 0.8
- externalScore = round(0.8 × 25) = 20.
If no recognized tags exist, externalScore = 0.
Section sources
Assume:
- Five distinct counterparties with externalScore = 25 each.
- MAX_EXTERNAL_SCORE = 25.
Computation:
- Each contributes 25 / 25 = 1.0.
- Sum = 5.0.
- propagationScore = min(5, floor(5.0)) = 5.
If ten counterparties have externalScore = 12.5:
- Each contributes 12.5 / 25 = 0.5.
- Sum = 5.0.
- propagationScore = 5.
Section sources
On-chain consumer checks:
- Call
meetsThreshold(didHash, 50). - Returns true if
getTotalScore(didHash) >= 50.
Consumers should use getTotalScore for spendable thresholds, not getEarnedScore, because maturity gates when a score becomes usable.
Section sources
The reputation system depends on several modules and contracts:
graph TB
REP["SigvaraReputation.sol"]
ORACLE["oracle/index.js"]
SCORING["oracle/scoring.js"]
PAYMENTS["oracle/payments.js"]
EXTERNAL["oracle/external.js"]
MERKLE["oracle/merkle.js"]
CHALLENGE["packages/sdk/src/challenge.ts"]
ORACLE --> SCORING
ORACLE --> PAYMENTS
ORACLE --> EXTERNAL
ORACLE --> MERKLE
ORACLE --> REP
CHALLENGE --> REP
Diagram sources
- index.js:1-22
- scoring.js:1-8
- payments.js:1-27
- external.js:1-17
- merkle.js:1-17
- SigvaraReputation.sol:22-78
- challenge.ts:1-10
Section sources
- Decay arithmetic: Uses scaled integers to preserve precision for 18-decimal tokens.
- Grouping by payer: Reduces repeated traversal of payment events across factors.
- Merkle tree construction: O(E log E); cached per evidence set.
- External feedback reads: Per-client iteration with timeouts; fail-safe returns zero.
- Maturity reads: Extrapolated on read to allow accrual even if oracle stops proposing.
Common issues and resolutions:
- Attestation rejected due to RPC error: Provider unavailable; retry later. Do not treat as negative outcome.
- Settlement hash not found or unconfirmed: Ensure minimum confirmations met and transaction mined.
- Self-payment detected: Payer equals operator or agent address; use a distinct counterparty.
- External trust zero despite ERC-8004 setup: Verify environment configuration and NFT ownership.
- Merkle proof verification fails: Check leaf encoding, settledAt units (seconds), and outcome codes.
- Challenge response replayed: Nonce reuse is rejected; generate a fresh challenge.
Section sources
- payment-backed-attestations.md:105-117
- payment-backed-attestations.md:183-234
- external.js:150-168
- challenge.ts:78-87
Sigvara’s reputation system combines on-chain economic signals, external trust registries, and community feedback into a robust 0–100 score. Its design emphasizes verifiability through Merkle proofs, resistance to sybil and farm-and-cash-out attacks through decay, maturity, and bonding, and transparency through public evidence and challenge mechanisms. Consumers should gate on getTotalScore and meetsThreshold, while auditors can reconstruct evidence from chain data and compare against on-chain roots.
- Agent Registration and Lifecycle
- Contract Overview and Architecture
- Economic Security Model and Incentives
- Evidence Verification and Merkle Proofs
- Key Management and Rotation
- Maturity Mechanism and Score Release
- Proposal Workflow and Challenge System
- Score Storage and Data Model
- SigvaraIdentity Contract
- SigvaraOracleBond Contract
- SigvaraReputation Contract
- SigvaraStaking Contract
- Slashing Lifecycle and Dispute Resolution
- Stake Management Functions
- Status Management and Control
- Token and Fee Contracts
- Unbonding Period and Withdrawal Security
- Anti-Manipulation and Security Measures
- Community Flag Processing
- Evidence Sources and Verification
- External Trust Integration
- Merkle Proof System
- Oracle Score Computation
- Payment-Backed Attestations
- Scoring Model and Formulas
- Agent Creation and Key Management
- Agent Operations
- Agent Registration Workflow
- Challenge-Response Authentication
- Gate Access Control
- Integration Patterns and Examples
- SDK Overview and Setup
- Verifier Functions