aotrust-protocol SDK
Asyncio-native Python SDK for the AOTrust Notary API — cryptographic proof-of-existence for AI agent outputs.
Why protocol-level proofs? An ERC-8004 empirical study (2026) measured that >98% of agent feedback records carry no proof of an underlying interaction (no payment proof, no task linkage); 59–91% of reviewers on three chains participated in coordinated Sybil campaigns, and manipulating a reputation score past a trust threshold costs as little as $0.0027. The agentic economy is moving from statements to verifiable claims: a PDR (239 bytes, Ed25519-signed, hash-chained, NEAR-anchored) turns any output or payment into independent evidence — verifiable by anyone, without trusting the provider's database. (Refs: arXiv:2610.12948 [cs.CR], 2026; ERC-8004 Sybil measurements, Xiong et al. 2026.)
Install
pip install aotrust-protocol
Quickstart
Free tier — no API key, no wallet (fastest way to try)
import asyncio, hashlib
from agent_notary import NotaryClient
async def main():
# IMPORTANT: no /v1 suffix — the SDK appends API paths itself.
client = NotaryClient(base_url="https://api.aotrust.link")
work_hash = hashlib.sha256(b"my artifact text").hexdigest()
result = await client.shield_free(work_hash)
job_id = result["job_id"] # keep this UUID — it is the handle
print("job_id:", job_id)
# Check status BY job_id (not by the artifact text!)
status = await client.get_status(job_id)
print("status:", status.status) # PENDING → anchored (anchor batches)
# Fetch + verify the PDR
pdr = await client.get_pdr(job_id)
print("verify in browser:", pdr.verify_url)
assert (await client.verify_pdr(pdr.pdr_b64))["valid"]
asyncio.run(main())
Free tier: 5 PDR / 24h per IP. Examples: examples/04_free_tier.py.
Witness mode (pre-paid tx_hash)
import asyncio
from agent_notary import NotaryClient, NotarizeRequest
async def main():
client = NotaryClient(
api_key="your-api-key",
base_url="https://api.aotrust.link" # no /v1 suffix!
)
# Submit notarization
req = NotarizeRequest(
tx_hash="EzrfDW5b...",
work_hash="599d6999...",
agent_sig="base64_sig_A...",
agent_pubkey="aff91a18...",
)
result = await client.notarize(req)
print(f"Job: {result.job_id}")
# Poll for PDR — status/pdr calls always take the job_id returned above
status = await client.wait_for_pdr(result.job_id, timeout=60)
if status.is_anchored:
pdr = await client.get_pdr(result.job_id)
assert pdr.verify(client.notary_pubkey)
print("PDR Valid: YES")
asyncio.run(main())
Why no
/v1?base_urlmust behttps://api.aotrust.link. The SDK already builds/v1/...request paths; adding/v1yourself produces/v1/v1/...→ HTTP 404 on every call. This bit a real user (2026-09-29: quickstart copy-paste + status lookups by artifact text instead of job_id).
Paid read products (2.5.0)
The SDK never signs or settles payments itself: a paid call first raises
NotaryPaymentError, whose message carries the server's x402 challenge. Pay
with any x402-capable client and retry with X-PAYMENT (HTTP) or
x402/payment (MCP); the SDK then parses the 200 response.
from agent_notary import NotaryClient
from agent_notary.exceptions import NotaryPaymentError, NotaryPendingError
client = NotaryClient()
# Evidence pack — $0.02. Default = earliest issuance; seq selects one.
pack = await client.bundle(work_hash) # dict: picked/issuances/anchor/verify
pack_at_158 = await client.bundle(work_hash, seq=158)
# Signed time attestation — $0.002.
attest = await client.time_attest(payload_hash) # id/ts/sig_b64/leaf/log_index/anchor
# Idempotent lookup by payment tx — free. A 404 is a normal answer.
found = await client.pdr_by_tx("0x" + "ab" * 32) # {"found": False} when unknown
# Anchor API — free.
status = await client.anchor_status() # mode/latest/log_size
proof = await client.anchor_proof(186) # RFC 9162 §2.1.3 path
logproof = await client.anchor_logproof(381) # Phase B, kind 0/1
cons = await client.anchor_consistency(62, 64) # RFC 9162 §2.1.4
try:
pack = await client.bundle(work_hash)
except NotaryPaymentError as e:
print("Pay via x402, then retry with X-PAYMENT / x402/payment:", e)
except NotaryPendingError as e:
print(f"Anchor not committed yet; retry in {e.eta_seconds}s at {e.recheck_url}")
Configuration
| Env Var | Constructor Arg | Description |
|---|---|---|
NOTARY_API_KEY |
api_key |
API key for auth |
NOTARY_API_URL |
base_url |
API base URL |
NOTARY_PUBKEY |
notary_pubkey |
Notary Ed25519 public key (hex) |
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /v1/notarize |
Submit notarization |
| GET | /v1/status/{job_id} |
Poll job status |
| GET | /v1/pdr/{job_id} |
Get PDR |
| POST | /v1/notarize/quote |
Get price quote |
| GET | /.well-known/agent.json |
MCP Server Card |
| POST | /notarize |
Anonymous x402 paid PDR ($0.01) |
| POST | /v1/attestation/bundle |
Evidence pack ($0.02) |
| POST | /v1/attest/time |
Signed time attestation ($0.002) |
| GET | /v1/pdr/verify/{pdr_b64} |
Verify a PDR |
| GET | /v1/pdr/by-tx/{tx} |
PDR by payment tx |
| GET | /v1/anchor/status |
Cumulative anchor status |
| GET | /v1/anchor/proof/{seq} |
Inclusion proof by ledger seq |
| GET | /v1/anchor/logproof/{log_index} |
Inclusion proof by log index (Phase B) |
| GET | /v1/anchor/consistency?from=&to= |
Consistency proof |
| GET | /openapi.json |
OpenAPI 3.0 spec |
PDR Verification
pdr = await client.get_pdr(job_id)
is_valid = pdr.verify(notary_pubkey_hex="9c7d64bb...")
Uses NEP-413 raw-buffer verification. No SHA256 pre-hash.
Error Handling
from agent_notary.exceptions import (
NotaryAuthError, # 401 (authenticated CI surfaces; anonymous x402 gives 402 instead)
NotaryPaymentError, # 402 x402-challenge / 403
NotaryNotFoundError, # 404
NotaryPendingError, # 404 NOT_YET_ANCHORED — retry after eta_seconds
NotaryValidationError, # 400/422 — invalid params, INVALID_AGENT_SIGNATURE
NotaryConflictError, # 409 — tx_hash/job_id already used (idempotency)
NotaryServerError, # 5xx, carries status_code
NotaryError, # base — safety net
)
try:
result = await client.notarize(req)
except NotaryAuthError:
print("Invalid API key")
except NotaryPaymentError as e:
print(f"Payment/sig failed: {e}")
except NotaryValidationError as e:
print(f"Bad request or invalid signature: {e}")
except NotaryConflictError:
print("This tx_hash/job_id was already used — generate a new one")
except NotaryError as e:
print(f"Other SDK error: {e}")
Development
pip install -e ".[dev]"
pytest tests/ -v
Payment binding (NEAR rail)
NEAR payments must be provably linked to the account that sent them. Pass
payer_account (the NEAR account that paid) together with bind_sig — a
base64 Ed25519 NEP-413 raw-buffer signature (no SHA-256 pre-hash) over:
AOTrust AITP-BIND v1
work_hash:<64 hex>
tx_hash:<tx hash exactly as submitted>
The server resolves the account's public key via RPC and checks
transaction.signer_id == payer_account; a mismatch is rejected with
403 PAYMENT_BIND_SIGNER_MISMATCH, a bad signature with
403 PAYMENT_BIND_INVALID.
If NEAR_PRIVATE_KEY is set in the environment (or near_private_key= is
passed), the SDK signs the canonical message itself and fills bind_sig:
req = NotarizeRequest(tx_hash=tx, work_hash=wh)
await client.notarize(req, payer_account="alice.near")
Server mode AITP_BIND_MODE=warn (default) accepts unbound requests with a
PAYMENT_UNBOUND log line; enforce requires the fields.
Metadata
Release files for aotrust-protocol 2.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aotrust_protocol-2.5.1.tar.gz | 20.9 kB | With provenance | Details for aotrust_protocol-2.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aotrust_protocol-2.5.1-py3-none-any.whl | Python 3 | none | any | Details for aotrust_protocol-2.5.1-py3-none-any.whl |
Total release size: 35.7 kB
Release files / aotrust_protocol-2.5.1.tar.gz
| Download URL | aotrust_protocol-2.5.1.tar.gz |
|---|---|
| Size | 20.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77e4de9559bd7f85166e2ee1fe5fcaa5b4888bb2036cbe56632631b3cff7c723
|
|
BLAKE2b-256 checksum How to use checksums |
8c9e418777786cdaab66e3bd37216cb77847e53c066c9a046871c69daaaf506a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / aotrust_protocol-2.5.1-py3-none-any.whl
| Download URL | aotrust_protocol-2.5.1-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
764755be63e0a519fa18c6f91ba64f11f03e04ca897c60a73cf8a8a0649670c6
|
|
BLAKE2b-256 checksum How to use checksums |
ac7e653eceee7eb1939493230b98356b71fae143bc7a832b0e889db55be99f73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logSecurity for aotrust-protocol 2.5.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for aotrust_protocol-2.5.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logA 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.