aws-samples / aws-samples/sample-agentcore-cloudfront-x402-payments
Add x402-agentpay as optional commerce middleware (escrow + reputation + batch settlement)
- Dominant language
- Python
- Stars
- 25
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
## Add x402-agentpay as Commerce Middleware Option
Hi AWS team 👋 — great work on this repo, it is the clearest x402 reference implementation on AWS infrastructure we have seen.
We are building [x402-agentpay](https://x402-agent-pay.com) — a commerce layer that sits **on top of** the x402 transport (and on top of AgentCore Payments) to add:
- **Escrow** — lock funds until service delivery is confirmed, not just "payment sent"
- **Capability registry** — agents advertise what they do and what they charge per capability
- **Reputation scoring** — on-chain track record per agent address before trusting it
- **Permission grants** — delegated spend authority across agent hierarchies
- **Batch settlement** — settle 100s of micro-transactions in a single on-chain call
- **X-PAYMENT v3 header** — enriched with `ledger_id`, `receipt_hash`, `scope`, `capability`, `grant_id`
### Why this complements AgentCore (not competes with it)
AgentCore handles **signing + wallet management** (transport). AgentPay handles the **commerce logic**:
| Question | AgentCore answers? | AgentPay answers? |
|---|---|---|
| Was the payment signed correctly? | ✅ | — |
| Was the content actually delivered? | ❌ | ✅ (escrow) |
| Does this agent have a good track record? | ❌ | ✅ (reputation) |
| Can I batch 1000 micro-payments? | ❌ | ✅ (batch settlement) |
| Who authorized this spend? | ❌ | ✅ (permission grants) |
### Integration (3 lines of code)
```python
pip install x402-agentpay
```
```python
from x402_agentpay import AgentPayClient
agentpay = AgentPayClient(api_base="https://x402-agent-pay.com/api", agent_address="0xYourWallet", api_key="YOUR_KEY")
# Wrap the ProcessPayment call with escrow
escrow = agentpay.escrow.create(x402_payload=x402_payload, capability="content_access", auto_release_seconds=300)
payment_header = agentpay.build_payment_header(x402_payload=x402_payload, escrow_id=escrow["escrow_id"])
# Retry CloudFront request with enriched X-PAYMENT v3 header
response = requests.get(content_url, headers={"X-PAYMENT": payment_header})
```
### Request
Would you be open to:
1. Adding a `docs/agentpay-middleware.md` integration guide to this repo?
2. Mentioning AgentPay as an optional commerce middleware in the README under "Extensions"?
We have written a full integration guide here: https://x402-agent-pay.com/protocol
Happy to open a PR with the doc if you prefer. Architecture is patent pending. Built on Base mainnet.
— Shawn Lippert, AgentPay / x402AgentPay LLC
Contributor guide
Research direction
Start with the repository README and the requested docs/agentpay-middleware.md file, then review the existing AgentCore and x402 integration documentation. Confirm whether this external middleware fits the project before documenting the proposed integration, and ensure the README extension and guide agree on the supported workflow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, blockchain, python
- Domain
- cloud, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100