Catalog PyPI
Back to packageRELEASE DETAILS

0.2.0

PyPI

agentescrow402

Python SDK, LangChain tool, MCP server, and CLI for AgentEscrow402 — trustless AI agent escrow payments on Casper Network

ai-agentscaspered25519escrowweb3x402
Published29 Jul 2026
Direct dependencies10
Transitive dependenciesNot calculated

README

Version 0.2.0 documentation

AgentEscrow402 SDK

Python SDK, LangChain Tool, and MCP Server for trustless AI agent escrow payments on Casper Network.

Python 3.10+ License: MIT 26 MCP Tools 62 API Endpoints Live


Overview

This directory contains three integration layers for AgentEscrow402:

ComponentFileDescription
Python SDKclient.pyAsync client with Ed25519 signing, full escrow lifecycle
CLIcli.pyae402 console script — thin wrapper over the SDK
Verifierverify.pyOffline Ed25519 verification of arbiter multisig votes
LangChain Toollangchain_tool.pyDrop-in EscrowPaymentTool for any LangChain agent
MCP Servermcp_server.py26 tools for any MCP-compatible LLM (Claude, GPT, etc.)

2-minute quickstart

For judges and first-time developers. Zero config, zero secrets, works against the live sandbox.

# 1. clone + install (30s)
git clone https://github.com/alexbelij/AgentEscrow402.git
cd AgentEscrow402
pip install httpx cryptography pydantic

# 2. run the quickstart (60s)
python examples/quickstart.py --api-url https://agentescrow402-api-ywm8.onrender.com

Expected output (real testnet, one create + one release):

connected: {'status': 'ok', ...}
buyer identity: <64-hex>
escrow created: <service_hash> status=created
escrow released: status=released deploy_hash=<hex>

That's it. The deploy_hash links to cspr.live if you want to inspect the on-chain state yourself.

What just happened

  1. EscrowClient.generate() produced a fresh Ed25519 identity (no wallet setup, no funded testnet account required for the sandbox flow).
  2. create_escrow produced a signed request; the server locked funds and returned a service_hash you can reference later.
  3. release produced another signed request; the server released the funds and returned a deploy_hash.

For the full autonomous buyer/seller/arbiter loop (with a real dispute and an LLM arbitration call), run:

python examples/escrow_agent.py --api-url https://agentescrow402-api-ywm8.onrender.com

Next steps

  • LangChain: drop EscrowPaymentTool into any agent — see sdk/langchain_tool.py.
  • MCP: expose 26 escrow tools to Claude / GPT / any MCP client — see sdk/mcp_server.py.
  • Judging: docs/HOW_TO_JUDGE.md maps the 8 criteria to concrete files and endpoints.

Quick Start

Install

pip install httpx cryptography pydantic
# For MCP server:
pip install mcp
# For LangChain:
pip install langchain

Python SDK — 3 lines to create an escrow

from sdk.client import EscrowClient

async with EscrowClient.generate("https://agentescrow402-api-ywm8.onrender.com") as client:
    escrow = await client.create_escrow(
        receiver="ab" * 32,  # receiver's 64-hex Casper account hash
        amount=5000,
        ttl=300
    )
    print(f"Escrow created: {escrow['service_hash']}")
    
    # Release funds after work is delivered
    await client.release(escrow["service_hash"], amount=5000)

LangChain — drop-in tool

from sdk.langchain_tool import EscrowPaymentTool

tool = EscrowPaymentTool("https://agentescrow402-api-ywm8.onrender.com", sender="agent-001")

result = await tool.run("create", receiver="ab" * 32, amount=5000)
result = await tool.run("release", service_hash=result["service_hash"])
result = await tool.run("reputation", agent="agent-001")

Supported actions: create, release, refund, dispute, status, reputation, batch_release, batch_cancel, claim_stream, risk

MCP Server — any LLM manages escrows

# stdio (default — for Claude Desktop, Cursor, etc.)
python -m sdk.mcp_server

# SSE (for remote/web connections)
pip install mcp[sse] uvicorn starlette
python -m sdk.mcp_server --transport sse --port 8402

Authentication

Signed mode (production)

The live API verifies Ed25519-signed X-Payment headers on every request. EscrowClient.generate() handles this automatically:

from sdk.client import EscrowClient

# Auto-generates a keypair and signs all requests
async with EscrowClient.generate("https://agentescrow402-api-ywm8.onrender.com") as client:
    print(client.sender)  # your 64-hex Ed25519 public key

To reuse the same identity across runs:

from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey

key = Ed25519PrivateKey.generate()  # persist this for reuse
client = EscrowClient("https://agentescrow402-api-ywm8.onrender.com", private_key=key)

Sandbox mode (local development)

async with EscrowClient("http://localhost:8000", sender="agent-001", sandbox=True) as client:
    escrow = await client.create_escrow(receiver="ab" * 32, amount=5000, ttl=300)

SDK Client Methods

MethodDescription
create_escrow(receiver, amount, ttl)Lock funds in a new escrow
release(service_hash, amount)Release funds to receiver
refund(service_hash)Return funds to sender
dispute(service_hash, reason_hash)Open a dispute
get_escrow(service_hash)Get escrow status and details
list_escrows(status, limit, offset)List escrows with filters
get_reputation(agent)Query on-chain reputation score
get_stats()Aggregate escrow statistics
batch_release(service_hashes)Release multiple escrows atomically
batch_cancel(service_hashes)Cancel multiple pending escrows
build_x402_header(service_hash, amount)Build x402 payment header

MCP Tools (26)

DomainToolDescription
Escrowcreate_escrowLock funds between sender and receiver
release_escrowRelease funds to receiver
refund_escrowReturn funds to sender
dispute_escrowOpen a dispute on active escrow
get_escrowFetch escrow status and details
list_escrowsList escrows with status filter
get_escrow_historyFull state-change history
build_x402_headerBuild x402 payment header
compute_hashCompute deterministic service hash
estimate_feeEstimate fees and insurance cost
Reputationget_reputationQuery agent's on-chain reputation
list_agentsList all agents with scores
get_statsAggregate escrow statistics
get_eventsRecent escrow events
health_checkAPI and blockchain health
Arbitrationsubmit_dispute_arbitrationSubmit for AI-assisted arbitration
get_arbitration_resultGet AI verdict and reasoning
appeal_arbitrationAppeal within allowed window
Riskcalculate_risk_scoreIsolationForest anomaly detection
get_risk_dashboardAggregated risk scores
Identityregister_identityRegister agent with public key
get_identityLook up agent identity
Advancedelect_arbiterVRF-based on-chain arbiter election
batch_releaseRelease multiple escrows atomically
batch_cancelCancel multiple pending escrows
claim_streamClaim fully-vested streaming escrow

x402 Payment Header

The x402 protocol header format used by the live API:

x402-v1;<escrow_hash>;<amount>;<sender>;<timestamp>;<nonce>;<signature>

Where signature = Ed25519.sign(key, "x402-v1;<escrow_hash>;<amount>;<sender>;<timestamp>;<nonce>;<METHOD>;<path>"), binding it to the exact HTTP method and path.


Examples


Documentation

DocumentDescription
SDK GuideFull SDK documentation with examples
API / SDK / MCP ReferenceComplete 62-endpoint REST API reference
ArchitectureSystem architecture and design decisions
OpenAPI SpecMachine-readable API specification
MCP Tools SchemaMCP tool definitions (JSON)
Console (interactive)Live interactive API/SDK/MCP documentation

Live Resources

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 10

Native requirements
10 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
cryptography
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
cryptography>=41runtime
httpx
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
httpx>=0.24runtime
pydantic
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pydantic>=2.0runtime
mypy
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
mypy>=1.5; extra == "dev"runtime
pytest-asyncio
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest-asyncio>=0.21; extra == "dev"runtime
pytest-httpx
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest-httpx>=0.28; extra == "dev"runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest>=7.0; extra == "dev"runtime
ruff
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
ruff>=0.1; extra == "dev"runtime
langchain
Environment
{
  "extras": "",
  "marker": "extra == \"langchain\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
langchain>=0.1; extra == "langchain"runtime
mcp
Environment
{
  "extras": "",
  "marker": "extra == \"mcp\"",
  "requires_python": ">=3.10",
  "evaluation": "NOT_EVALUATED"
}
mcp<2,>=0.9; extra == "mcp"runtime

Distribution files

2 collected
agentescrow402-0.2.0-py3-none-any.whl

bdist_wheel · 69.53 KB · Python py3

Source file
agentescrow402-0.2.0.tar.gz

sdist · 90.79 KB · Python source

Source file

Repository

PENDING
alexbelij/agentescrow402

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:52 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:93aa973093de9482be6dcbaace61c67deed8b777a59d71f006f2de3397bbdff7

Other collected versions

View all collected versions →