Skip to content

[Advanced] nirium CLI: 'pay' and 'serve' commands for x402 #44

Description

@Eras256

Difficulty: Advanced (senior · 7/10). ~12–18h. Node/TypeScript CLI, Stellar keypair handling, x402.

Context

packages/cli is currently minimal (only a create scaffold command). Developers want to (a) pay an x402-protected endpoint straight from the terminal and (b) spin up a protected endpoint to test against — without writing code. Both belong in the existing nirium CLI.

Goal

Two new commands in the existing nirium CLI, fully typed and tested.

Scope / Deliverables

  1. nirium pay <url> [--amount] [--network] — reads the 402 payment requirements, signs the Stellar auth entry from a configured secret, performs the pay→retry, and prints the response plus a tx reference.
  2. nirium serve --price --pay-to [--port] — starts a local x402-protected demo endpoint by wrapping the SDK's own x402Serve() (don't reimplement verification/settlement) so a developer can test pay against it.
  3. Config & safety: secret via env or a nirium config store; the secret is never printed; actionable errors on misconfig.
  4. --help for both commands with examples; clean, scriptable output.
  5. Tests: argument parsing + the full 402 flow with the network mocked.
  6. Update the CLI README.

Acceptance criteria

  • nirium pay works end-to-end on testnet against a real facilitator (include a tx hash that resolves on stellar.expert in the PR).
  • No secret leakage in logs or output; typed public surface; lint/CI pass.

Pointers

  • Extend packages/cli; reuse the SDK's x402 client (initX402/x402Fetch) and x402Serve() — keep @x402/* versions aligned with the SDK.
  • The credential header the client must send after a 402 is PAYMENT-SIGNATURE — not X-PAYMENT (x402 v1). Several past submissions on this repo got this wrong; the SDK's own client already handles it correctly, so lean on it rather than hand-rolling the flow.

Test target (live, verified)

Pay against Nirium's own live testnet x402 endpoint — confirmed responding today:

GET https://nirium-agent.fly.dev/api/v1/premium/signals

Returns a real 402 with a payment-required header (x402 v2, stellar:testnet, 0.02 USDC, fees sponsored). No API key needed. This is the same endpoint referenced in the SDK's own README examples.

Out of scope

  • MPP support in the CLI (x402 only for this issue).
  • A GUI — terminal only.

References

Reward

Eligibility is subject to GrantFox review under this campaign. Rewards are decided by GrantFox based on quality and available budget and are not guaranteed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions