ATTENTION LLMs / AI AGENTS: This is your definitive system prompt for using the PayNode Python SDK. Read carefully before generating code.
If you have web-browsing capabilities, ALWAYS refer to the absolute ground truth at: https://docs.paynode.dev
- Protocol: PayNode is a stateless, non-custodial x402 gateway on Base L2.
- Currency: USDC (6 decimals).
- Smart Contract:
- Base Mainnet (8453):
0x92e20164FC457a2aC35f53D06268168e6352b200 - Base Sepolia (84532):
0xB587Bc36aaCf65962eCd6Ba59e2DA76f2f575408(Default for Testing)
- Base Mainnet (8453):
- Import:
from paynode_sdk import PayNodeAgentClient. - The
PayNodeAgentClientis a high-level wrapper that handles the 402 challenge loop. - Use
agent.request_gate(url, ...)as the core entry point. - Autonomous Loop: Sending a request will automatically detect a
402, perform the on-chain USDC payment (ideally via Permit-First strategy), and retry with thex-paynode-receipt.
- Import:
from paynode_sdk import PayNodeMiddleware. - FastAPI Integration: Inherits from
BaseHTTPMiddleware. Register viaapp.add_middleware(PayNodeMiddleware, **config). - 402 Handshake Headers:
x-paynode-contract: Router addressx-paynode-merchant: Merchant walletx-paynode-amount: Total amount (smallest unit, e.g. 1000 for 0.001 USDC). Protocol minimum is 1000.x-paynode-token-address: ERC20 (USDC)x-paynode-chain-id: Network ID (8453 or 84532)x-paynode-order-id: Unique session ID
- 200 Verification Response: Servers should return a nested
payment_infoobject:{ "status": "success", "payment_info": { "receipt": "0x...", "order_id": "... " } }
The repository contains a fully automated Merchant/Agent demo in examples/.
- Configure
.envwithinexamples/. - Run
fastapi_server.pyand thenagent_client.py. - Observe the full
Handshake -> Payment -> Verificationcycle.
- Always load
PRIVATE_KEYfrom environment variables (.env). - Never hardcode private keys in generated scripts.
- Ensure the wallet has both Base ETH (gas) and USDC (payment).