Skip to content

docs: add production patterns for x402 and MPP - #13

Closed
DarkMagician256 wants to merge 1 commit into
stellar:mainfrom
DarkMagician256:feat/production-patterns-x402-mpp
Closed

docs: add production patterns for x402 and MPP#13
DarkMagician256 wants to merge 1 commit into
stellar:mainfrom
DarkMagician256:feat/production-patterns-x402-mpp

Conversation

@DarkMagician256

Copy link
Copy Markdown

Summary

Adds production-ready patterns to x402.md and mpp.md based on running both protocols in production on Stellar. These patterns address gaps in the current documentation that developers encounter when moving from examples to real deployments.

x402.md additions:

  • Multi-route price table: per-endpoint pricing with paymentMiddlewareFromConfig
  • Graceful degradation: safe fallback when STELLAR_RECIPIENT is not configured (prevents crashes in CI/dev)
  • Payment receipt logging: async, non-blocking pattern for tracking revenue

mpp.md additions:

  • Dual-mode server: combining charge + channel in the same Express app with route-level intent selection
  • Per-route pricing: middleware factory pattern for different price tiers per endpoint
  • Recipient key auto-resolution: detects and derives public key when a secret key is accidentally set in container env vars (common Railway/Docker misconfiguration)
  • Discovery endpoint: /info pattern so clients can negotiate available intents

README.md:

  • Added x402/MPP example prompts to the "Example Prompts" section

Context

These patterns come from operating x402 + MPP in production on Stellar since before the x402 Foundation launch (April 2, 2026). The auto-resolution pattern in particular addresses a real-world issue we hit in containerized deployments on Railway.

Test plan

  • Verify markdown renders correctly on GitHub
  • Code examples are syntactically valid JS/TS
  • Patterns are consistent with existing x402.md and mpp.md style

🤖 Generated with Claude Code

Add real-world production patterns to x402.md and mpp.md based on
experience running both protocols in production on Stellar:

x402.md:
- Multi-route price table with per-endpoint pricing
- Graceful degradation when payment config is missing
- Payment receipt logging pattern

mpp.md:
- Combining charge + channel modes in the same server
- Per-route pricing with middleware factories
- Recipient key auto-resolution for containerized deployments
- Discovery endpoint pattern for client intent negotiation

Also add x402/MPP example prompts to README.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 10, 2026 19:17
@DarkMagician256
DarkMagician256 deleted the feat/production-patterns-x402-mpp branch April 10, 2026 19:22
aristidesstaffieri added a commit that referenced this pull request Jul 13, 2026
  Addresses the agent stress-test feedback on #55: repay full-close
  recipe (dToken round-up, #10/#1205 failure modes, buffer-first),
  min_collateral semantics (#1224, c_factor-adjusted, oracle decimals),
  --send=no on all reads + archived-state RestoreFootprint caveat,
  reward_zone() as the pool-discovery method (factory events are past
  RPC retention), the borrow-rate curve with exact scales (ir_mod 7dp
  [0.1,10], status enum, q4w_pct 7dp, get_tokens order), BLND trustline
  prerequisite for claims (#13), getting assets from XLM (borrow or
  path payment; two testnet USDCs), tx-new-vs-invoke submit semantics,
  resource-fee and timeout remediation notes, testnet-first env blocks,
  and a verified public mainnet RPC endpoint list in the standards
  skill (the CLI's built-in mainnet alias has no RPC URL).

  rank-backstops.sh now derives the backstop per network and fails
  loudly instead of printing nothing off-mainnet; verified against
  testnet and mainnet.
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