Skip to main content

XAP Protocol SDK — Settlement objects for autonomous agent commerce

Project description

XAP SDK

Settlement objects for autonomous agent commerce.

XAP is the only protocol combining schema validation, cryptographic signatures, enforced state machines, idempotency, governed receipts, and replayable reasoning into one governed object model.

CI PyPI Python License: MIT

Install

pip install xap-sdk

Quickstart: Two Agents, One Settlement, Full Provenance

import asyncio
from xap import XAPClient

# Create two agents with sandbox (fake money, no external services)
provider = XAPClient.sandbox(balance=0)
consumer = XAPClient.sandbox(balance=100_000)  # $1,000.00
consumer.adapter.fund_agent(str(provider.agent_id), 0)
provider.adapter = consumer.adapter

# Provider registers a capability
provider_identity = provider.identity(
    display_name="SummarizeBot",
    capabilities=[{
        "name": "text_summarization",
        "version": "1.0.0",
        "pricing": {"model": "fixed", "amount_minor_units": 500, "currency": "USD", "per": "request"},
        "sla": {"max_latency_ms": 2000, "availability_bps": 9950},
    }],
)
consumer.discovery.register(provider_identity)

# Consumer discovers and negotiates
results = consumer.discovery.search(capability="text_summarization")
offer = consumer.negotiation.create_offer(
    responder=provider.agent_id,
    capability="text_summarization",
    amount_minor_units=500,
)
accepted = provider.negotiation.accept(offer)

# Settle with full decision provenance
async def settle():
    settlement = consumer.settlement.create_from_contract(
        accepted_contract=accepted,
        payees=[{"agent_id": str(provider.agent_id), "share_bps": 10000}],
    )
    locked = await consumer.settlement.lock(settlement)
    result = await consumer.settlement.verify_and_settle(
        settlement=locked,
        condition_results=[{
            "condition_id": "cond_0001", "type": "deterministic",
            "check": "output_delivered", "passed": True,
        }],
    )

    # Verify the decision is deterministically replayable
    assert consumer.receipts.verify_replay(result.verity_receipt)
    print(f"Settlement: {result.receipt['outcome']}")
    print(f"Replay verified")
    return result

asyncio.run(settle())

What XAP Does

XAP is a settlement object protocol. Every agent-to-agent economic interaction produces governed objects that are:

  • Schema-validated — structured, machine-readable
  • Cryptographically signed — Ed25519, tamper-evident
  • State-transitioned — explicit state machines, no implicit jumps
  • Idempotent — safe retries, no duplicate effects
  • Receipted — every settlement emits a governed receipt
  • Replayable — every decision can be independently verified

The Stack

xap-protocol    — Open standard (MIT). The language agents speak.
verity-engine   — Open source truth engine (Rust). The Git of financial truth.
xap-sdk         — This package. Build with XAP in Python.
Agentra Rail    — Commercial infrastructure. The GitHub of agent settlement.

Examples

Example What it shows
Two-Agent Demo Full flow: discover, negotiate, settle, replay
Three-Agent Split Multi-party settlement with basis point splits
Unknown Outcome Partial settlement and refund scenarios

Key Concepts

Money is always integers. 500 means $5.00 (minor units). No floating point, ever.

Shares are basis points. 4000 means 40%. Shares must sum to exactly 10000.

Every decision is replayable. The VerityReceipt captures inputs, rules, computation steps, and a replay hash. Any party can independently verify the outcome.

Sandbox mode is zero-config. XAPClient.sandbox() gives you fake money, in-memory registry, and test adapter. No external services needed.

Links

License

MIT

Project details


Download files

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

Source Distribution

xap_sdk-0.3.0.tar.gz (53.1 kB view details)

Uploaded Source

Built Distribution

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

xap_sdk-0.3.0-py3-none-any.whl (56.5 kB view details)

Uploaded Python 3

File details

Details for the file xap_sdk-0.3.0.tar.gz.

File metadata

  • Download URL: xap_sdk-0.3.0.tar.gz
  • Upload date:
  • Size: 53.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for xap_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8cb4abb935db54a85e4d7a1fd57980b216c8a1db1fe35ef34f5e026b49e265a3
MD5 9f6f7184c966c7c316ce576151119672
BLAKE2b-256 42f0f300f7b6f244d8518f45ea22226217d6874a96fd4e8bb0a444ba8c5157b0

See more details on using hashes here.

File details

Details for the file xap_sdk-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: xap_sdk-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 56.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for xap_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ec99f6b55cf02ce89766c49d0a86b0942f7815da1ddbc070d04f15299f601b1
MD5 88b30d459328d00c7798106f917da62b
BLAKE2b-256 7d08dafa75149ebbf5704f698660ae8b656c3e12be394d45a4f22b8170057cf3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page