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/aeonfun/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.2

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.2
File Size Uploaded Provenance Actions
x402aff-0.4.2.tar.gz 53.2 kB With provenance Details for x402aff-0.4.2.tar.gz

Built distribution (wheel)

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

Total release size: 96.6 kB

Release files / x402aff-0.4.2.tar.gz

Download URL x402aff-0.4.2.tar.gz
Size 53.2 kB
Tags Source
SHA-256 checksum
How to use checksums
62a63bf6fb9eb621159767807bf90f8ac42351b5c5fc0e3e513ea48a32dad13a
BLAKE2b-256 checksum
How to use checksums
497c748cdba335b9e2e01809ffe2a1d576f5802bb6fbc36bb14f8a1e8909b218
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 Nov 28, 2026.

Transparency log

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

Download URL x402aff-0.4.2-py3-none-any.whl
Size 43.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92aac80da936470da432838f40d5b0e6525df8bae88107c353e7a867ba990128
BLAKE2b-256 checksum
How to use checksums
b4100383a786cb53b2ccd4558259005cbc1a38fe10e3d80eac7370cbb16b56ab
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 Nov 28, 2026.

Transparency log

Security for x402aff 0.4.2

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.2.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 Nov 28, 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