Non-custodial x402 payment client for autonomous AI agents on AiFinPay (Solana + Polygon)
Project description
aifinpay-agent (Python)
Non-custodial x402 payment client for autonomous AI agents on AiFinPay.
The Ed25519 keypair is generated locally and never leaves your process. The
SDK only sends a one-time SHA-256 + Ed25519 signature in the x-signature
header to authenticate against AiFinPay-protected endpoints.
Install
pip install aifinpay-agent
Quick start
from aifinpay import Agent
# Generate a fresh keypair locally — never transmitted
agent = Agent.new()
print("Fund this address:", agent.address)
print("Save this secret:", agent.secret_b58) # store securely!
# Wait until the wallet has at least $0.01 worth on-chain
agent.wait_for_funding(min_usd_cents=1)
# Request an invoice for a Seat (USDC on Solana)
invoice = agent.reserve_seat_invoice(amount_usd=1.00, asset="USDC")
print("Invoice:", invoice.raw)
# Build + sign + submit the Solana transaction with @solana/web3.js, anchorpy,
# or solana-py — the invoice contains program_id, treasury_vault, mints, etc.
# Once the Seat is on-chain, any AiFinPay-gated endpoint just works:
resp = agent.get("https://aifinpay.company/api/stats")
print(resp.json())
Loading an existing keypair
# from solana-keygen JSON file
agent = Agent.from_keypair_file("~/agent-wallet.json")
# from base58 secret string
agent = Agent.from_secret_b58("3RvZm7Gw...")
How x402 auth works under the hood
For every gated request the SDK:
GET /nonce→ receives a one-time UUID with 60s TTL- computes
SHA-256("AiFinPay-x402:{nonce}:{pubkey}") - signs with Ed25519, base58-encodes the signature
- retries the original request with headers:
x-agent-pubkey: <base58 pubkey>x-nonce: <uuid>x-signature: <base58 sig>
The server verifies the signature, checks the agent has a live Seat PDA on-chain, and serves the resource.
Privacy
- The server never sees your private key. Period.
- Nonces are consumed on use; replay-resistant.
- All transactions are public and on-chain — Solana + Polygon mainnet.
License
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aifinpay_agent-0.1.0a1.tar.gz.
File metadata
- Download URL: aifinpay_agent-0.1.0a1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b369501a477f3106231e1bbde552aabf9df3fcf14337517ab56593304358bc6a
|
|
| MD5 |
ae8cf1f6e1a4286e3d4a314768adcb42
|
|
| BLAKE2b-256 |
3a8729c6e5bf859a7f39badc990707d7d07d4468907861b9f533b5495524fa2d
|
File details
Details for the file aifinpay_agent-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: aifinpay_agent-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91075859b30005c28132421cd2894dfc9f53bb3aeabc227d7a86e29526e6576a
|
|
| MD5 |
4f2c180202d89c1791990b5455e0f693
|
|
| BLAKE2b-256 |
9f3bad1e37bbc593e3d400800ff52181f0b4602ae11635b8d821696bdd3fb303
|