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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

web3_agent_reputation-0.2.0.tar.gz (168.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

web3_agent_reputation-0.2.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file web3_agent_reputation-0.2.0.tar.gz.

File metadata

  • Download URL: web3_agent_reputation-0.2.0.tar.gz
  • Upload date:
  • Size: 168.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for web3_agent_reputation-0.2.0.tar.gz
Algorithm Hash digest
SHA256 45fe88795e1163d8b8265e005bcd494b833b0d072a6b8ee4e6571f66d9d54f61
MD5 ce14ab5646090c70835f739bd084d0e1
BLAKE2b-256 70e7d8203bad839ceb93e5ede4df586c766e327d76b0f224ffb4a88d6ba315ee

See more details on using hashes here.

File details

Details for the file web3_agent_reputation-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for web3_agent_reputation-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f21e39ddd10ddcedd537140d5c2c16639fef780e1cd61ea82f523223109804bc
MD5 9eedf9f55e984024b4eb1b6a3d6d4683
BLAKE2b-256 379c6282d2658df320d28bf6fe2490aa5d7c40217e9bde4da8446b988178b1dc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

0.0.1

2 files

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