Skip to content

Add stellar checkout to pay for x402-protected resources - #2886

Open
fnando wants to merge 9 commits into
mainfrom
checkout-x402
Open

fnando wants to merge 9 commits into
mainfrom
checkout-x402

Conversation

@fnando

@fnando fnando commented Nov 4, 2026

Copy link
Copy Markdown
Member

What

Adds stellar checkout <URL>, an x402 client. When the server responds with a 402, it builds and auth-signs a SEP-41 transfer and retries the request with the payment proof. The facilitator then submits it and pays the fees. Options: --max-amount sets a spend cap (default 1), --build-only prints the proof without paying, and --output json returns a receipt. Errors give the facilitator's reason, or name the account with a missing trustline or a low balance.

$ stellar checkout http://localhost:3001/protected/testnet --source payer
ℹ️ Received 402 Payment Required; building payment…
🌎 Submitting payment…
✅ Payment settled: f356e17b167823a4dda898b398e9f8ad3d111805c29840d3a12f7d50e1aa8811
🔗 https://stellar.expert/explorer/testnet/tx/f356e17b167823a4dda898b398e9f8ad3d111805c29840d3a12f7d50e1aa8811
<!DOCTYPE html>
...

Why

It lets Stellar users pay for x402-protected resources from the CLI with their existing identities and networks.

Known limitations

Only the exact scheme with fee-sponsoring facilitators is supported, and muxed payers aren't. Tested end to end against stellar/x402-stellar on testnet, which needs @x402/* ≥ 2.29.

@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Nov 4, 2026
@fnando fnando moved this from Backlog (Not Ready) to In Progress in DevX Nov 4, 2026
@fnando
fnando requested review from leighmcculloch and marcelosalloum and a balanced review from Copilot November 4, 2026 19:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical flaws can authorize transfers beyond the spend cap, exhaust client memory, and corrupt downloaded binary resources.

7 open issues
What changed in this PR

Adds stellar checkout <URL> to fetch x402-protected resources using existing Stellar identities and network configuration. Payments use authorization-signed SEP-41 transfers that a fee-sponsoring facilitator submits.

Changes:

  • Adds challenge selection, spend-cap enforcement, payment-proof construction, and HTTP replay.
  • Supports build-only proofs, JSON receipts, and payment failure diagnostics.
  • Registers the command, documents its options, and adds unit tests.
File Description
FULL_HELP_DOCS.md Documents checkout usage and options.
cmd/​soroban-cli/​src/​env_vars.rs Registers the checkout spend-cap environment variable.
cmd/​soroban-cli/​src/​commands/​pay/​payment.rs Builds payment proofs and diagnoses transfer failures.
cmd/​soroban-cli/​src/​commands/​pay/​mod.rs Coordinates checkout, proof output, and receipts.
cmd/​soroban-cli/​src/​commands/​pay/​http.rs Fetches resources and replays requests with payment proofs.
cmd/​soroban-cli/​src/​commands/​pay/​challenge.rs Parses challenges, selects payment options, and decodes settlements.
cmd/​soroban-cli/​src/​commands/​pay/​cap.rs Parses and enforces display-unit spending limits.
cmd/​soroban-cli/​src/​commands/​mod.rs Registers and dispatches the checkout command.
cmd/​soroban-cli/​src/​commands/​contract/​invoke.rs Adds authorization-only transaction construction for payment proofs.
cmd/​soroban-cli/​src/​cli.rs Integrates checkout with structured JSON error output.

Review effort: Balanced

Comment thread cmd/soroban-cli/src/commands/pay/cap.rs Resolved
Comment thread cmd/soroban-cli/src/commands/pay/mod.rs Resolved
Comment thread cmd/soroban-cli/src/commands/pay/mod.rs Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants