Python SDK for Observer Protocol — agent identity, delegation, x402 verification, and chargeback prevention
Project description
observer-protocol
Python SDK for Observer Protocol - agent identity, delegation, x402 verification, and chargeback prevention for the agentic economy.
Built on W3C DIDs and Verifiable Credentials. Type-hinted throughout.
Install
pip install observer-protocol
Quick Start
from observer_protocol import ObserverClient
client = ObserverClient()
# 1. Register an agent
pub, priv = ObserverClient.generate_keypair()
agent = client.register_agent(public_key=pub, agent_name="My Agent")
# 2. Verify key ownership
challenge = client.request_challenge(agent.agent_id)
sig = ObserverClient.sign_challenge(priv, challenge.nonce)
client.verify_agent(agent.agent_id, sig)
Delegation (Chargeback Prevention)
delegation = client.request_delegation(
agent_id="d13cdfceaa8f895afe56dc902179d279",
scope=["payments"],
rails=["x402-usdc-base", "lightning", "tron:trc20"],
spending_limits={"per_transaction": "100", "daily": "1000"},
attestation_tier="enterprise",
)
delegations = client.list_delegations()
client.revoke_delegation(delegation.request_id)
Magic Link (Human-in-the-Loop)
magic_link = client.generate_magic_link(
agent_id="d13cdfceaa8f895afe56dc902179d279",
counterparty_did="did:web:neuralbridge.ai",
counterparty_name="NeuralBridge",
amount="50.00", currency="USDT", rail="usdt-trc20",
purchase_description="GPU inference credits",
)
# Agent forwards magic_link.url to its human
result = client.get_magic_link_credential(magic_link.jti)
x402 Verification (USDC on Base)
result = client.verify_x402(
agent_id="d13cdf...", agent_did="did:web:...",
counterparty="did:web:hyperbolic.xyz",
amount="100000", resource_uri="https://...",
settlement_tx_hash="0x...", payment_payload={...},
)
print(result.verification.onchain_verified) # True
Chain Verification
client.verify_lightning(receipt_reference="...", payment_hash="...", preimage="...")
client.verify_tron(receipt_reference="...", tron_tx_hash="...")
Trust Score
score = client.get_trust_score("d13cdf...")
print(score.trust_score, score.components.receipt_score)
ERC-8004 On-Chain Registry
summary = client.get_8004_summary("d13cdf...")
client.pin_registration(agent_id="...", agent_did="...", agent_name="Maxi")
Links
License
MIT
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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 observer_protocol-0.2.0-py3-none-any.whl.
File metadata
- Download URL: observer_protocol-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc0a6a6163a554608bcba784028590e67d07e612b42fe33410eec646477e5854
|
|
| MD5 |
c6aa88b6e0d7f6a8898e4a7dc3cb91e7
|
|
| BLAKE2b-256 |
04151959c2d71d2c8bdb4655abcba4af0ce41e27260ccef73db5de350316a20c
|