Skip to content

feat: x402 micropayment support#2

Merged
plur9 merged 5 commits intomainfrom
feat/x402
Mar 3, 2026
Merged

feat: x402 micropayment support#2
plur9 merged 5 commits intomainfrom
feat/x402

Conversation

@plur9
Copy link
Contributor

@plur9 plur9 commented Mar 3, 2026

Summary

  • Add sellX402 and buyX402 CLI commands for x402 micropayment flow
  • Add x402 encryption helpers (AES-256-GCM) compatible with server-side decryption
  • Includes autonomous agent commands (watch, scan-bounties, batch sell)

Changes

  • src/commands/sellX402.ts — sell with x402 payment: encrypt → Swarm upload → register
  • src/commands/buyX402.ts — buy with x402: EIP-3009 authorization → facilitator settlement → download + decrypt
  • src/crypto/x402.ts — content encryption, key management, USDC formatting
  • Code review hardening: timeouts, URL encoding, error clarity

Test plan

  • All 383 unit tests pass (bun test)
  • Type check passes (tsc --noEmit)
  • E2E test on Base Sepolia (post-merge)
  • Production smoke test

🤖 Generated with Claude Code

plur9 and others added 5 commits February 5, 2026 10:01
Phase 0 — MCP compatibility fixes:
- Align Base mainnet contract to 0x69Aa385686AEdA505013a775ddE7A59d045cb30d
- Fix ECDH commit-reveal: commit against encrypted key when buyer pubkey known
- Add marketplace publishing to sell command
- Bridge MCP JSON key storage (~/.datafund/escrow-keys/) bidirectionally
- Extend CLIError with retryAfterSeconds, suggestedCommand, 10 new error codes
- Add HTTPS enforcement for API and RPC URLs

Phase 1 — New commands:
- `ade watch` — escrow automation daemon with NDJSON event protocol,
  three-tier spending limits, HMAC-SHA256 state integrity, PID-based locking
- `ade scan-bounties` — match local files to open bounties via keyword overlap,
  security filters for sensitive files, optional auto-respond mode
- `ade sell --dir` — batch sell files from directory with rate limiting,
  --skip-existing, --max-files, partial error reporting

Schema v1.1.0 with auth levels, credentials, protocols, error formats.
Version bumped to 0.2.0. 213 tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
AES-256-GCM encryption using IV(12)+authTag(16)+ciphertext layout
matching the agents-api x402-download handler. Includes key-length
validation and cross-format incompatibility tests proving escrow
and x402 formats are distinct.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add x402 micropayment support to the ade CLI:

- sellX402(): encrypt file with x402 format, upload to Swarm, publish
  with payment_method 'x402' and content key. No gas required.
- buyX402(): HTTP 402 payment flow with EIP-3009 USDC authorization,
  re-download support via tx_hash.
- Wire sell --payment x402 flag and buy-x402 meta command
- Add help text for both x402 flows
- Add ERR_PAYMENT_FAILED and ERR_PAYMENT_REQUIRED error codes
- 23 new tests (all passing, zero regressions)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add AbortSignal.timeout(30_000) to all raw fetch() calls in buyX402
- URL-encode skillId with encodeURIComponent to prevent injection
- Replace silent requirements[0] fallback with explicit error listing
  server-offered networks vs supported networks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@plur9 plur9 merged commit ab486f3 into main Mar 3, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant