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.
- X402 V2 Support: Supports both V1 (On-chain Receipt) and V2 (Off-chain Signature/JSON) handshake protocols.
- Currency: USDC (6 decimals).
- Smart Contract:
- Base Mainnet (8453):
0x4A73696ccF76E7381b044cB95127B3784369Ed63 - Base Sepolia (84532):
0x24cD8b68aaC209217ff5a6ef1Bf55a59f2c8Ca6F(Default for Testing)
- Base Mainnet (8453):
paynode_sdk/client.py:PayNodeAgentClientfor autonomous 402 loops (V1 & V2).paynode_sdk/middleware.py: FastAPI/StarlettePayNodeMiddleware.paynode_sdk/constants.py: Protocol constants (sync viascripts/sync-config.py).paynode_sdk/errors.py: Custom exceptions and protocol error codes.paynode_sdk/verifier.py: On-chain and Off-chain (EIP-3009) verification logic.examples/: Reference implementations for Agent and Merchant flows.
- Import:
from paynode_sdk import PayNodeAgentClient. - Use
agent.request_gate(url, ...)as the core entry point. - Autonomous Loop: Automatically detects
402, performs USDC payment (EIP-2612 Permit or EIP-3009 Authorization), and retries. - Always provide
rpc_urlsas a list for failover support.
- FastAPI Integration:
app.add_middleware(PayNodeMiddleware, **config). - Handshake Headers:
x-paynode-contract,x-paynode-merchant,x-paynode-amount(min 1000),x-paynode-chain-id. - Response Format: Return
payment_infoobject withreceiptandorder_idon success.
- Testing: Use
pytest. Test files located intests/. - Command:
PYTHONPATH=. pytest tests/ - Build:
python -m buildfor distribution. - Linting: Follow PEP 8. Use
blackorruffif available.
- No Sync in Async: Don't use blocking
requestsinside async FastAPI routes. Usehttpx. - Checksum Addresses: Always use
Web3.to_checksum_address(). - Decimal Precision: Never use floats for USDC. Use integers (smallest unit).
- Gas Handling: Don't hardcode
gasPrice. Useweb3.eth.generate_gas_price()or 1.2x multiplier. - Event Polling: Avoid tight loops for transaction receipts. Use
web3.eth.wait_for_transaction_receipt.
- Configure
.envinexamples/. - Run
fastapi_server.pythenagent_client.py. - Check
mint_test_tokens.pyfor Sepolia USDC setup.
- Load
PRIVATE_KEYviaos.getenv(). Never hardcode. - Verify wallet has Base ETH for gas and USDC for payments.
- Protocol minimum payment is 1000 units (0.001 USDC).