Skip to main content

x402aff - Python

PyPI Python versions License: MIT

The x402aff kit (Python): an installable x402aff package with the one-object Affiliation facade on top. This is the implementation validated end-to-end on Base mainnet.

Install

pip install x402aff                  # from PyPI
pip install 'x402aff[cdp]'           # with the CDP discovery extra

Or from a checkout / straight from git, to track unreleased changes:

pip install ./python                 # from a clone, at the repo root
pip install '.[cdp]'                 # from inside python/, with the CDP extra
pip install 'x402aff[cdp] @ git+https://github.com/MiroShark/x402aff@main#subdirectory=python'

The cdp extra adds cdp-sdk, needed only for the CDP-index discovery path (monitor, aff.scan() / pending() / splits_payload()). Without it the request-time payTo and payout-calldata paths work fine.

Vendoring instead of installing works too - copy python/x402aff/ into your project as a subpackage; the modules import each other relatively, so nothing needs rewriting and none of the generic names (split, monitor, resolver) leak into your top-level namespace.

Use

from x402aff import Affiliation

aff = Affiliation(app_code="bc_yourcode", seller_payout="0xYourWallet")

# on your x402 route:
#   pay_to=aff.pay_to           per-request split, from the X-Builder-Code header
#   extensions=aff.extensions   declares your app code `a`

# release payouts, later (permissionless):
calls, balance = aff.release("bc_alice")

aff.resolve(request) returns the full PayTo, including status (resolved / unregistered / blocked / invalid / error / none). Echo it in the aff.STATUS_HEADER (X-Builder-Code-Status) response header so a builder can tell a working code from an unminted or mistyped one.

Full integration guide (money path, trust model, wiring, caveats): ../docs/INTEGRATION.md. The TypeScript port lives in ../ts/ and resolves the identical split address.

Modules

File Role
__init__.py The package's public surface (from x402aff import Affiliation, …).
affiliation.py Start here. The Affiliation facade wrapping everything below.
builder_code.py Declare a; decode a/s/w off a settle tx.
resolver.py Builder code → registered payout address (one eth_call).
split.py Builder code + price → the split plan (recipients + bps).
push_split.py The plan → 0xSplits calldata + counterfactual address.
payto.py Request-time payTo resolver. Cached, never raises.
distribute.py The (deploy + distribute) calldata to release a funded split.
monitor.py Which splits hold distributable funds (via CDP's index).
buyer_client.py Buyer-side extension that attaches s (via marked_service_codes).
cdp_sql.py · queries.sql CDP SQL API client + attribution queries.

Develop

pip install -e '.[cdp,dev]'   # editable install with the CDP + test extras
pytest                        # runs tests/ against the x402aff package

Metadata

Release files for x402aff 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for x402aff 0.4.1
File Size Uploaded Provenance Actions
x402aff-0.4.1.tar.gz 53.2 kB With provenance Details for x402aff-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for x402aff 0.4.1
File Interpreter ABI Platform Actions
x402aff-0.4.1-py3-none-any.whl Python 3 none any Details for x402aff-0.4.1-py3-none-any.whl

Total release size: 96.6 kB

Release files / x402aff-0.4.1.tar.gz

Download URL x402aff-0.4.1.tar.gz
Size 53.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5e3b65aad804d8b5bf3e86d10fb093556639f74123cbfaf0cf686aa333833d80
BLAKE2b-256 checksum
How to use checksums
5c68c3e8b26f36e6c722abf93c81559519a05fef180aeb0c3e398fe8b327ca8f
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 Oct 29, 2026.

Transparency log

Release files / x402aff-0.4.1-py3-none-any.whl

Download URL x402aff-0.4.1-py3-none-any.whl
Size 43.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1f5130e13a47507259e5af41a5fda73909049f6fff00a7ff74de673d4dbdc98
BLAKE2b-256 checksum
How to use checksums
12e8a23f62f7185073c64f3fb3e925aacfb6ecabc68d8e1ba88b2470d37a0016
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 Oct 29, 2026.

Transparency log

Security for x402aff 0.4.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.

Select from 2 files

Attestation for x402aff-0.4.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 Oct 29, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page