Skip to main content

web3-agent-reputation

ERC-8004 Trustless Agents — a web3.py external module (facts layer) plus a pure reputation calculator. The Python member of the agent-reputation-sdk family; numerically identical to the TypeScript agent-reputation package against the shared golden vectors in vectors/.

Install

pip install web3-agent-reputation
# or, in this repo, from the packages/py directory:
uv sync

Requires Python >=3.10 and web3>=6.

The two-layer contract

Facts layer — thin typed reads through your existing Web3 client; no opinions:

from web3 import Web3
from web3_agent_reputation import ERC8004Module

w3 = Web3(Web3.HTTPProvider("https://mainnet.base.org"),
          external_modules={"erc8004": ERC8004Module})
# or, post-construction: w3.attach_modules({"erc8004": ERC8004Module})

agent = w3.erc8004.get_agent(1)                  # Agent(agent_id, owner, token_uri, registered_at)
feedback = w3.erc8004.get_agent_feedback(1)       # list[FeedbackEntry]
validations = w3.erc8004.get_agent_validations(1) # list[ValidationEntry]
reg_file = w3.erc8004.get_registration_file(1)    # verified: True | False | None

Chain detection is automatic (w3.eth.chain_id at call time) against a 7-chain ERC-8004 registry table (Ethereum, Base, Polygon, Arbitrum, Optimism, BNB, Gnosis) — an unsupported chain raises ChainUnsupportedError.

Calculator layer

A pure function; your policy in, evidence-rich result out — never a bare scalar. Every result carries expectation, uncertainty, witness statistics, honesty caveats, and the echoed policy (the reproducibility manifest):

from web3_agent_reputation import calculate_reputation, activity_sqrt

rep = calculate_reputation(feedback, witness_cap=1, credibility=activity_sqrt(distinct_counts))
# Reputation(expectation=0.665, uncertainty=0.179, witnesses=20, entries=..., 
#            top_witness_share=0.15, caveats=[...], policy={...})

calculate_reputation accepts anything with .client/.score attributes (including the FeedbackEntry returned by get_agent_feedback directly) — see src/web3_agent_reputation/calculator.py for the full normative algorithm description, copied verbatim from the TypeScript reference.

The no-bare-scalar principle

A single reputation number invites false confidence: it hides how many witnesses backed it, whether one dominant client inflated it, and what policy produced it. Every Reputation this package returns is a small evidence bundle instead — witnesses, entries, top_witness_share, and caveats travel with expectation/uncertainty so a caller can judge how much to trust the number, not just read the number. The calculator computes what you asked for under a policy you declared; it does not define "the" score for any agent — judgment stays with the consumer.

Errors

Erc8004Error is the base class; subclasses are AgentNotFoundError, ChainUnsupportedError, RpcError, FileUnreachableError, FileHashMismatchError, InvalidInputError. See src/web3_agent_reputation/errors.py.

Tests

uv run pytest              # unit + golden-vector conformance, no network
uv run pytest -m live       # live smoke test against Base public RPC (deselected by default)

Example

examples/vet_agent.py — given an agent id and a chain RPC URL, prints the facts and calculated reputation (both variants) for that agent: a pre-delegation guard in ~40 lines.

uv run python examples/vet_agent.py --agent-id 1 --rpc-url https://mainnet.base.org

Metadata

Release files for web3-agent-reputation 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for web3-agent-reputation 0.2.0
File Size Uploaded Provenance Actions
web3_agent_reputation-0.2.0.tar.gz 168.3 kB Without provenance Details for web3_agent_reputation-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for web3-agent-reputation 0.2.0
File Interpreter ABI Platform Actions
web3_agent_reputation-0.2.0-py3-none-any.whl Python 3 none any Details for web3_agent_reputation-0.2.0-py3-none-any.whl

Total release size: 191.6 kB

Release files / web3_agent_reputation-0.2.0.tar.gz

Download URL web3_agent_reputation-0.2.0.tar.gz
Size 168.3 kB
Tags Source
SHA-256 checksum
How to use checksums
45fe88795e1163d8b8265e005bcd494b833b0d072a6b8ee4e6571f66d9d54f61
BLAKE2b-256 checksum
How to use checksums
70e7d8203bad839ceb93e5ede4df586c766e327d76b0f224ffb4a88d6ba315ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / web3_agent_reputation-0.2.0-py3-none-any.whl

Download URL web3_agent_reputation-0.2.0-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f21e39ddd10ddcedd537140d5c2c16639fef780e1cd61ea82f523223109804bc
BLAKE2b-256 checksum
How to use checksums
379c6282d2658df320d28bf6fe2490aa5d7c40217e9bde4da8446b988178b1dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for web3-agent-reputation 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page