{"id":46867867,"url":"https://github.com/rplryan/x402-payment-harness","last_synced_at":"2026-03-24T21:00:49.977Z","repository":{"id":341085166,"uuid":"1168719238","full_name":"rplryan/x402-payment-harness","owner":"rplryan","description":"EOA-based Python library + CLI for testing x402 payments. Full HTTP 402 → EIP-712 sign → X-PAYMENT header flow. No CDP wallet required.","archived":false,"fork":false,"pushed_at":"2026-02-27T21:39:33.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-28T02:12:28.934Z","etag":null,"topics":["base-network","coinbase","eip-712","testing-tools","usdc","web3-payments","x402"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/x402-payment-harness/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rplryan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-27T18:06:42.000Z","updated_at":"2026-02-27T21:39:36.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rplryan/x402-payment-harness","commit_stats":null,"previous_names":["rplryan/x402-payment-harness"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rplryan/x402-payment-harness","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rplryan%2Fx402-payment-harness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rplryan%2Fx402-payment-harness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rplryan%2Fx402-payment-harness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rplryan%2Fx402-payment-harness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rplryan","download_url":"https://codeload.github.com/rplryan/x402-payment-harness/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rplryan%2Fx402-payment-harness/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30905699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-24T08:58:18.477Z","status":"ssl_error","status_checked_at":"2026-03-24T08:57:59.595Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base-network","coinbase","eip-712","testing-tools","usdc","web3-payments","x402"],"created_at":"2026-03-10T19:00:20.186Z","updated_at":"2026-03-24T21:00:49.947Z","avatar_url":"https://github.com/rplryan.png","language":"Python","funding_links":[],"categories":["🔧 Server Frameworks \u0026 Middleware"],"sub_categories":["Python"],"readme":"# x402 Payment Harness\n\n[![PyPI version](https://img.shields.io/pypi/v/x402-payment-harness.svg)](https://pypi.org/project/x402-payment-harness/)\n[![PyPI downloads](https://img.shields.io/pypi/dm/x402-payment-harness.svg)](https://pypi.org/project/x402-payment-harness/)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Tests](https://img.shields.io/badge/tests-4%20passing-brightgreen.svg)](https://github.com/rplryan/x402-payment-harness/tree/main/tests)\n[![Network: Base](https://img.shields.io/badge/network-Base-0052FF.svg)](https://base.org)\n\n```bash\npip install x402-payment-harness\n```\n\n**The missing developer tool for x402.** Test any x402-protected endpoint from your terminal or Python code — no Coinbase Developer Platform wallet required. Just a standard Ethereum private key.\n\n```python\nfrom x402_harness import X402Client\n\nclient = X402Client(private_key=\"0xYOUR_PRIVATE_KEY\")\nresponse = client.get(\"https://api.example.com/premium-data\")\nprint(response.json())\n```\n\nThe client handles the full `HTTP 402 → EIP-712 sign → X-PAYMENT header → 200 OK` flow automatically.\n\n---\n\n## Why This Exists\n\nThe [x402 protocol](https://x402.org) is the emerging standard for HTTP-native micropayments on Base — enabling AI agents, APIs, and services to charge per-request without subscriptions or API key billing.\n\n**The problem:** The reference x402 implementation is built around Coinbase Developer Platform (CDP) managed wallets, which abstract away the signing logic — but require account creation, KYC-adjacent onboarding, and vendor lock-in. This is a real friction point for:\n\n- 🔧 **Server builders** who want to test their x402 endpoint as a client would\n- 🤖 **Agent developers** integrating x402 payments into autonomous workflows\n- 🧪 **Protocol researchers** exploring x402 behavior across different servers\n- 🏃 **Teams running CI/CD** who need deterministic, reproducible payment tests\n\n**This library removes that barrier entirely.** Any standard Ethereum EOA private key works — MetaMask export, hardware wallet, generated test key. No CDP account, no onboarding, no dependency on Coinbase infrastructure.\n\nThis is the **only Python x402 client library with native EIP-712 `TransferWithAuthorization` signing**.\n\n---\n\n## Installation\n\n```bash\npip install x402-payment-harness\n```\n\nRequires Python 3.8+. For development/testing:\n\n```bash\ngit clone https://github.com/rplryan/x402-payment-harness\ncd x402-payment-harness\npip install -e \".[dev]\"\n```\n\n---\n\n## Quick Start\n\n### CLI — One Command Payments\n\n```bash\n# Pay and fetch in one command\nx402-pay --url https://api.example.com/premium-data --key 0xYOUR_PRIVATE_KEY\n\n# Inspect every step of the payment flow\nx402-pay --url https://api.example.com/premium-data --key 0xYOUR_PRIVATE_KEY --verbose\n\n# POST request with JSON body\nx402-pay --url https://api.example.com/generate --key 0xYOUR_PRIVATE_KEY \\\n  --method POST --data '{\"prompt\": \"Hello, world\"}'\n```\n\n### Python Library\n\n```python\nfrom x402_harness import X402Client\n\n# Initialize with any standard EOA private key\nclient = X402Client(\n    private_key=\"0xYOUR_PRIVATE_KEY\",\n    network=\"base-mainnet\"       # default; also supports \"base-sepolia\"\n)\n\n# GET request — handles full 402 → sign → retry flow automatically\nresponse = client.get(\"https://api.example.com/premium-data\")\n\nif response.status_code == 200:\n    print(\"Payment accepted:\", response.json())\n\n# POST with body\nresponse = client.post(\n    \"https://api.example.com/generate\",\n    json={\"prompt\": \"Analyze this market data\"}\n)\n\n# Access payment details from the last transaction\nprint(client.last_payment)  # {amount, recipient, signature, nonce, ...}\n```\n\n---\n\n## How It Works: The x402 Protocol Flow\n\nWhen you call `client.get(url)`, the harness executes the complete x402 client protocol:\n\n```\n┌──────────┐    GET /premium-data       ┌──────────────────┐\n│  Client  │ ──────────────────────────►│  x402 Server     │\n│  (you)   │◄────────────────────────── │                  │\n└──────────┘   402 + X-PAYMENT-REQUIRED  └──────────────────┘\n      │         {amount, payTo, chainId,                ▲\n      │          EIP-712 domain separator}              │\n      │                                                 │\n      ▼ Sign TransferWithAuthorization                  │\n  EOA Private Key                                       │\n  eth_account.sign_typed_data()                         │\n      │                                                 │\n      ▼                                                 │\n┌──────────┐    GET /premium-data       ┌──────────────────┐\n│  Client  │ ──────────────────────────►│  Verify EIP-712  │\n│  (you)   │   + X-PAYMENT: \u003cbase64\u003e   ►│  signature ✓     │\n└──────────┘◄────────────────────────── │  Return 200 OK   │\n              200 OK + response body    └──────────────────┘\n```\n\n**Steps executed automatically:**\n1. Initial HTTP request to target endpoint\n2. Receive `402 Payment Required` with `X-PAYMENT-REQUIRED` header\n3. Parse EIP-712 domain separator and `TransferWithAuthorization` message struct\n4. Sign the struct using your EOA private key via `eth_account`\n5. Base64-encode the signed payload and attach as `X-PAYMENT` header\n6. Retry the request — server verifies signature and responds `200 OK`\n\n\u003e **On settlement:** This harness implements the complete x402 **client-side** protocol — producing valid, spec-compliant `TransferWithAuthorization` EIP-712 signatures. Server-side on-chain USDC settlement via `receiveWithAuthorization` is the facilitator's responsibility. The harness is the correct tool for testing and validating the client flow against any x402-compliant server.\n\n---\n\n## Use Cases\n\n### 🔨 Server Development \u0026 Testing\nBuilding an x402-protected API? Use this harness as your client to test every payment edge case — invalid signatures, expired nonces, wrong amounts — without building a custom test client.\n\n```python\nimport pytest\nfrom x402_harness import X402Client\n\ndef test_my_api_accepts_valid_payment():\n    client = X402Client(private_key=TEST_KEY)\n    response = client.get(\"http://localhost:8000/protected\")\n    assert response.status_code == 200\n```\n\n### 🤖 AI Agent Integration\nAutonomous agents can make x402 payments without managed wallet infrastructure:\n\n```python\nfrom x402_harness import X402Client\n\n# Agent pays for data, processes result, continues workflow\nclient = X402Client(private_key=os.environ[\"AGENT_WALLET_KEY\"])\nmarket_data = client.get(\"https://x402-api.example.com/prices\").json()\nagent.process(market_data)\n```\n\n### 🔄 CI/CD Integration\nAdd x402 protocol conformance tests to your pipeline:\n\n```yaml\n# .github/workflows/test.yml\n- name: Test x402 payment flow\n  run: x402-pay --url ${{ env.TEST_SERVER_URL }} --key ${{ secrets.TEST_WALLET_KEY }}\n```\n\n### 🔍 Protocol Exploration\nExplore any x402 endpoint on the network:\n\n```bash\n# Discover services via x402 Discovery API, then test them\nx402-pay --url https://x402-discovery-api.onrender.com/discover --key 0xYOUR_KEY --verbose\n```\n\n---\n\n## Features\n\n| Feature | Description |\n|---|---|\n| **Full protocol flow** | HTTP 402 challenge → EIP-712 sign → `X-PAYMENT` header, end-to-end |\n| **EOA support** | Works with any standard Ethereum private key — no CDP wallet required |\n| **ERC-3009 signing** | Native `TransferWithAuthorization` EIP-712 typed data signing |\n| **CLI tool** | `x402-pay --url \u003cendpoint\u003e` for fast terminal testing |\n| **Python library** | `X402Client` with `get()` and `post()` methods |\n| **Base mainnet proven** | Confirmed working against live Base USDC x402 endpoints |\n| **Test suite** | 4 passing automated tests covering core protocol flows |\n| **Zero vendor lock-in** | Pure open source, no CDP dependency, no API keys needed |\n\n---\n\n## Testing\n\n```bash\npytest tests/ -v\n```\n\nAll 4 tests pass without any API keys or live network connections — the test suite uses fixtures to mock the 402 challenge/response cycle. This makes it suitable for CI/CD without wallet credentials.\n\n---\n\n## Part of the x402 Infrastructure Suite\n\nThis library is part of a suite of open-source tools built to make x402 practical:\n\n| Tool | What It Does | Status |\n|---|---|---|\n| **x402 Payment Harness** | EOA-based client library and CLI for testing x402 | **This repo** |\n| **[x402 Discovery API](https://github.com/rplryan/x402-discovery-api)** | Searchable registry of 251+ live x402-enabled services with health signals | [Live](https://x402-discovery-api.onrender.com) |\n| **[x402 Discovery MCP](https://github.com/rplryan/x402-discovery-mcp)** | MCP server exposing Discovery API to Claude, Cursor, Windsurf | [Published](https://registry.modelcontextprotocol.io) |\n| **[x402 RouteNet](https://github.com/rplryan/x402-routenet)** | Intelligent routing across x402 services with health-aware fallback | [Live](https://x402-routenet.onrender.com) |\n\nTogether these tools cover the three layers every developer needs: **discover** x402 services, **route** to the best one, and **test** the payment flow end-to-end.\n\n---\n\n## Links\n\n- **PyPI:** https://pypi.org/project/x402-payment-harness/\n- **x402 Protocol:** https://x402.org\n- **x402 Discovery API:** https://x402-discovery-api.onrender.com\n- **Base Network:** https://base.org\n\n---\n\n## License\n\nMIT © 2024 rplryan\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frplryan%2Fx402-payment-harness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frplryan%2Fx402-payment-harness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frplryan%2Fx402-payment-harness/lists"}