PayNode Python SDK
The official Python SDK for the PayNode Protocol (v2.2.1). PayNode allows autonomous AI Agents to seamlessly pay for APIs and computational resources using USDC on Base L2, utilizing the standardized HTTP 402 protocol with support for both on-chain receipts and off-chain signatures (EIP-3009).
📖 Read the Docs
For complete installation guides, advanced usage, API references, and architecture details, please visit our official documentation: 👉 docs.paynode.dev
⚡ Quick Start
Installation
pip install paynode-sdk-python web3
Agent Client (Payer)
from paynode_sdk import PayNodeAgentClient
agent = PayNodeAgentClient(
private_key="YOUR_AGENT_PRIVATE_KEY",
rpc_urls=["https://mainnet.base.org", "https://rpc.ankr.com/base"]
)
# Automatically handles the 402 challenge, executes the Base L2 transaction, and gets the data.
response = agent.request_gate("https://api.merchant.com/premium-data", method="POST", json={"agent": "PythonAgent"})
print(response.json())
Key Features (v2.2.1)
- EIP-3009 Support: Sign payments off-chain using
TransferWithAuthorization, allowing for gasless or relayer-mediated settlement. - X402 V2 Protocol: JSON-based handshake for more structured and machine-readable payment instructions.
- Dual Flow: Automatic fallback to V1 (on-chain receipts) for legacy merchant support.
- FastAPI Middleware: Easy-to-use middleware for merchants to protect their API routes.
🗺️ Roadmap
- TRON Support: USDT (TRC-20) payment integration.
- Solana Support: SPL USDC/USDT payment integration.
- Cross-chain: Universal settlement via bridges.
🚀 Run the Demo
The SDK includes a complete Merchant/Agent demo in the examples/ directory.
1. Setup Environment
Copy the example environment file and fill in your keys:
cp .env.example .env
# Edit .env with your private key and RPC URLs
2. Get Test Tokens (Required for Base Sepolia)
If you're testing on Sepolia, run the helper script to mint 1,000 mock USDC:
python examples/mint_test_tokens.py
3. Run the Merchant Server (FastAPI)
python examples/fastapi_server.py
4. Run the Agent Client
In another terminal:
python examples/agent_client.py
The demo will perform a full loop: 402 Handshake -> On-chain Payment -> 200 Verification.
📦 Publishing to PyPI
To publish a new version of the SDK:
- Install build tools:
pip install build twine
- Build the package:
python -m build
- Upload to PyPI:
python -m twine upload dist/*
Built for the Autonomous AI Economy by PayNodeLabs.
Metadata
Release files for paynode-sdk-python 2.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| paynode_sdk_python-2.5.1.tar.gz | 32.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| paynode_sdk_python-2.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 59.9 kB
Release files / paynode_sdk_python-2.5.1.tar.gz
| Download URL | paynode_sdk_python-2.5.1.tar.gz |
|---|---|
| Size | 32.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd865af2c7395242d43d01c2c53131838efab76b5663237dc4a188891eb1fffe
|
|
BLAKE2b-256 checksum How to use checksums |
a52bfdbeb8cf69149737bb5585460b96b488f287212c1c4c486fb17966665313
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / paynode_sdk_python-2.5.1-py3-none-any.whl
| Download URL | paynode_sdk_python-2.5.1-py3-none-any.whl |
|---|---|
| Size | 27.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c81971a434d779e57f5c42d4d55218c6ae30c5a4a147557e59bb187c6a203326
|
|
BLAKE2b-256 checksum How to use checksums |
1445ce889575c688d733416498ef4eddee0c0fa458fd1dc0d2c1c14db491ff7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|