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 / 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.0

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.0
File Size Uploaded
x402aff-0.4.0.tar.gz 50.2 kB Details

Built distribution (wheel)

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

Total release size: 92.3 kB

Release files / x402aff-0.4.0.tar.gz

Download URL x402aff-0.4.0.tar.gz
Size 50.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0be16046c39a0bea11196483d4f516fdb0d957c9b90354b2c587921fdc8c23e8
BLAKE2b-256 checksum
How to use checksums
f2ebd212b99868304c53f0fa507105b131a64abbbc6ed767c1807681f0a62e33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 6, 2026.

Transparency log

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

Download URL x402aff-0.4.0-py3-none-any.whl
Size 42.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b48c6067dbb22586925a4d1dd4bca17f7677e6e68a85338c450c9a4dc6057f25
BLAKE2b-256 checksum
How to use checksums
658e0592bad65cdf943e21d0820383946d7db366f90f44f2c11978faa40bddb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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