ERC-8004 Trustless Agents: web3.py external module (facts layer) + a pure reputation calculator
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file web3_agent_reputation-0.1.0.tar.gz.
File metadata
- Download URL: web3_agent_reputation-0.1.0.tar.gz
- Upload date:
- Size: 166.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c90e641541c6f07a2dbcb44dd4f247211c64379fe28104521fb9c6cafee60a38
|
|
| MD5 |
b46e71a2cca76ceb5547ea7855380064
|
|
| BLAKE2b-256 |
5a7ef33aa60e6925f8319497850decf94e9bf2d19963473052760a65414505f6
|
File details
Details for the file web3_agent_reputation-0.1.0-py3-none-any.whl.
File metadata
- Download URL: web3_agent_reputation-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a81bd32cb951ad14ed74437205b9d884b51cb4f0ab60bae4227d86b8c8c99d9
|
|
| MD5 |
294e3cc58be54dc9a8f8b5a6e6c63b69
|
|
| BLAKE2b-256 |
7c31bead991e43e6839b1d0fe0af98692cae91263cb70099dc8e145c7d65c3bd
|