Try an x402 payment in one command (try-x402)

Trying x402 normally means writing a client first, which is where most people stop. try-x402 is that client as one command.

Read the payment terms, pay nothing

npx try-x402 --dry-run

That calls a paid endpoint, prints what it costs, which chain it settles on, and who gets paid, then exits without spending anything. It works against any x402 server, not just DeskCrew:

npx try-x402 --dry-run --url https://your-server.example/paid

Actually pay

Drop --dry-run and supply a wallet that already holds USDC:

export X402_KEY=0xyour_private_key
npx try-x402

With no key it generates a throwaway wallet. That wallet has no money, so it will tell you so and stop rather than wait around.

What it protects you from

It signs authorizations that move real money, so it refuses rather than trusts:

  • USDC only. If a server quotes a different token, it stops. The signing domain is built from a local table, so a server cannot choose which contract your signature binds to.
  • A price ceiling. 1 USDC by default, --max-price to raise it. Without a ceiling, the only check is whether you can afford the amount, and a hostile endpoint satisfies that by quoting exactly your balance.
  • Authorizations expire in 10 minutes, however long the server asks for.
  • Unknown flags are fatal. A silently ignored --dry-run would be a silent payment.

Use a throwaway wallet anyway.

Pointing it at an MCP server

MCP endpoints answer JSON-RPC, so they need a tool call rather than an empty body:

npx try-x402 --url https://deskcrew.io/api/mcp/deskcrew \
  --body '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"draft_support_reply","arguments":{"customer_message":"my order is late"}}}'

For agents

--json prints a machine-readable result instead of prose, including the dialect, chain, price, recipient, and whether anything was paid.

npx try-x402 --dry-run --json

Source and issues: https://github.com/webmilmind1/try-x402 (MIT)

Related articles