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.2.0.tar.gz (45.0 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.2.0-py3-none-any.whl (47.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xap_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 45.0 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.2.0.tar.gz
Algorithm Hash digest
SHA256 500e57ed795273597419c1bf637b5160267bc7a420c4dbe585c2d4e9a375e1ee
MD5 10c601db9354c2cd1761a2aa8fb1d473
BLAKE2b-256 3daa78bd6dc4bede2038027c7b5f93708b85fe94458e4cd41a409049e8c1b473

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xap_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 47.9 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bfe5c090aec7aa8e0e5a95678b52de77f15f2bd689c50d9ae3451d76b4b4745d
MD5 0a087e68ab4045ccbfcee37105043cd4
BLAKE2b-256 a6f74e36ab777e5a0ef50775a495b5b9a477e56d425a2f50443a7ee4446a6f28

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