Skip to main content

rsoft-trust (Python)

On-chain trust scores, policy gates and trust-based pricing for AI agents — the RSoft Trust API (AgentTrust-8004 on Base mainnet) as an async SDK on httpx. Python 3.10+.

pip install rsoft-trust            # not published yet — build from source, see below
pip install "rsoft-trust[fastapi]" # + the FastAPI dependency
from rsoft_trust import TrustClient

async with TrustClient() as trust:                # public deployment by default
    r = await trust.evaluate("0xB684…2B13", policy="financial", include_pricing=True, base_price_usdc=0.10)

r["trust_score"]     # 24
r["trust_tier"]      # "untrusted" | "limited" | "verified" | "trusted" | "blocked"
r["all_passed"]      # False
r["gate_results"]    # [{"gate": "established", "passed": False, "value": 4.06, "threshold": 30}, …]
r["pricing"]["price_multiplier"]   # 1.64 → suggested_price_usdc 0.164

await trust.require(wallet, "strict") is evaluate() that raises TrustGateError (with .failed_gates and .to_dict()) when the policy fails.

What the score is made of (and what it is not)

Every gate is derived from signals the API reads on-chain, today: ERC-8004 identity (registered), identity age (established), reputation clients (active), census coherence (coherent) and the 0–100 score. There is no KYC, sanctions or off-chain gate — the model does not have one. Full gate/tier/pricing tables: API README.

Policies

await trust.evaluate(wallet, "quick")        # registered
await trust.evaluate(wallet, "basic")        # + coherent
await trust.evaluate(wallet, "standard")     # + score ≥ 40   (default)
await trust.evaluate(wallet, "strict")       # + 90 d, 5 clients, score ≥ 75
await trust.evaluate(wallet, "financial")    # + 30 d, 3 clients, score ≥ 50
await trust.evaluate(wallet, "reputation")   # weighted vote ≥ 0.60

await trust.evaluate(wallet, {"gates": ["registered", {"gate": "score", "threshold": 60}], "operator": "AND"})

FastAPI dependency — rsoft_trust.fastapi.require_trust

from fastapi import Depends, FastAPI
from rsoft_trust.fastapi import require_trust

app = FastAPI()

@app.get("/paid", dependencies=[Depends(require_trust(policy="financial"))])
async def paid():
    ...

@app.get("/tier")
async def tier(verdict: dict = Depends(require_trust("standard"))):
    return {"tier": verdict["trust_tier"]}       # also on request.state.trust

Wallet comes from the X-Wallet header, then ?wallet= (override with wallet_from=lambda request: ...). No wallet → 401 · malformed → 400 · policy failed → 403 with detail = {error, trust_score, trust_tier, failed_gates, gate_results} and an X-Trust-Tier header · Trust API unreachable → 502 (never fail-open on a real verdict).

Pricing

include_pricing=True (or await trust.pricing(wallet, base_price_usdc)) returns:

  • price_multiplier ∈ [0.5, 2.0] — 2.0 − 1.5·score/100; anomaly or unregistered → 2.0.
  • suggested_interest_rate — indicative annual rate on the RSoft Bank's own scale (its formula in the zero-exposure limit); None for CCC/D. The Bank quotes its own rate; this is a hint, not a quote.

Client options

TrustClient(
    base_url=DEFAULT_BASE_URL,   # public RSoft Trust deployment
    api_key=None,                # sent as X-API-Key; reserved — the public API is unauthenticated today
    timeout=45.0,                # cold on-chain reads take ~10–30 s
    transport=None,              # httpx transport (tests)
    client=None,                 # bring your own httpx.AsyncClient
)

Errors: TrustApiError (.status, .body; status 0 for transport errors), TrustGateError from require(), ValueError for a malformed wallet (checked before any request).

Build from source

cd packages/rsoft-trust-py
pip install -e ".[dev]" && python -m pytest -q
python -m build            # → dist/rsoft_trust-0.1.0-py3-none-any.whl + .tar.gz

Download files

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

Source Distribution

rsoft_trust-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

rsoft_trust-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file rsoft_trust-0.1.0.tar.gz.

File metadata

  • Download URL: rsoft_trust-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.7

File hashes

Hashes for rsoft_trust-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b63bf6316afd546992d2f031229b4879e0aa8c95c0f938b0d89939c7d7d2ceaf
MD5 1dc55d376d60fbc060b497f5fc2fb84e
BLAKE2b-256 43675bf24dfce912ce07c246ec5080377aa3eda02ede9a017df1f63230076a63

See more details on using hashes here.

File details

Details for the file rsoft_trust-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rsoft_trust-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.7

File hashes

Hashes for rsoft_trust-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9c3f8fb632f6c3c9c1af8845fa77d56d89ea538592439adc90c91d6b52cb137b
MD5 7aa022c3ecc35eb477466f3b97b071f1
BLAKE2b-256 9d9379620cfe99cebfe8cd787eeffcb1484c789232041c39373e80e46c743912

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

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