examples: switchboard_x402_client — Rust ↔ Python interop demo#14
Merged
Merged
Conversation
Adds examples/switchboard_x402_client.rs — an arka-based agent calling a paid endpoint served by Python switchboard's HTTP-402 middleware. Proves the wire format (PaymentOffer / PaymentProof JSON envelopes) is genuinely language-neutral: arka has no switchboard dependency, just parses and emits the agreed shape. What the example does: - Creates a fresh arka Agent on Base - GET endpoint cold; expects 402 + X-Payment-Required header - Parses the accepts[] envelope (matches switchboard.x402_middleware.PaymentOffer) - Builds an X-Payment-Proof header (matches switchboard.x402_middleware.PaymentProof) - Retries with the proof; expects 200 The tx-hash is stubbed for the demo (real settlement would go through arka's wallet or switchboard's AgentEscrow contract via alloy). The point is the wire — bytes leaving this Rust process round-trip through the Python middleware's PaymentProof.from_header() without loss. Why this matters - The stack scene in switchboard's lab (web/agents-demo.html scene 09) names arka as a "consumer" — this example backs that claim with runnable code. - When the spec evolves (PQ envelope #33, receipt aggregation #43, privacy-preserving x402 #44), this example is the canary that catches wire drift between the Rust and Python sides. Adversarial conformance harness #45 will eventually run this as a fixture. Also updates examples table in README.md. Cross-references - switchboard repo: https://github.com/kcolbchain/switchboard - switchboard live lab: https://kcolbchain.github.io/switchboard/agents-demo.html - switchboard PR for PQ: kcolbchain/switchboard#33 cargo check passes clean (no warnings).
Contributor
|
Welcome to kcolbchain, @Pattermesh — glad you're here. 🌱 Here's what happens from this PR:
While you wait:
What happens after your first merge
Thanks for writing the code. We're building this to last. |
Contributor
|
🤖 Audit verdict: Example file demonstrating HTTP-402 payment interop with proper error handling, no hardcoded secrets, ephemeral wallet generation, and mocked transaction for demo purposes only. Audited by the kcolbchain PR pipeline. See pipeline docs. |
Contributor
|
Merged — thank you, @Pattermesh. Your first kcolbchain contribution is in. 🎉 A few things that unlocked with this merge:
If you want to stay in the loop on what we're shipping: https://kcolbchain.com/ROADMAP.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds `examples/switchboard_x402_client.rs` — an arka-based agent calling a paid endpoint served by Python switchboard's HTTP-402 middleware. Proves the wire format (`PaymentOffer` / `PaymentProof` JSON envelopes) is genuinely language-neutral: arka has no switchboard dependency, it just parses and emits the agreed shape.
What the example does
The tx-hash is stubbed for the demo (real settlement would go through arka's wallet or switchboard's `AgentEscrow` contract via alloy). The point is the wire — bytes leaving the Rust process round-trip through the Python middleware's `PaymentProof.from_header()` without loss.
Why this matters
Tests
`cargo check --example switchboard_x402_client` passes clean (no warnings). The example is run-only (needs the Python middleware up); it's not part of the default test suite.
Other changes
cc @abhicris
🤖 Generated with Claude Code