Skip to content

madisoncarter1234/x402-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

x402-cli

CLI for testing x402 payment endpoints.

What it does

  • Test x402 endpoints and make payments
  • Discover available x402 endpoints
  • Check payment requirements without paying
  • Verify transactions on-chain

Installation

npm install -g x402-cli

Or use directly with npx:

npx x402-cli <command>

Quick Start

Check what an endpoint accepts:

x402 info https://api.example.com/resource

Find available x402 APIs:

x402 discover

Test paying for something:

x402 test https://api.example.com/resource --key YOUR_PRIVATE_KEY

Commands

x402 test <url>

Test an endpoint by making a payment.

Options:

  • -k, --key <privateKey> - Private key for signing payments (or set X402_PRIVATE_KEY env var)
  • -a, --amount <amount> - Override payment amount
  • -v, --verbose - Show detailed payment flow

Example:

x402 test https://api.example.com/weather --verbose

x402 discover

Find x402 endpoints.

Options:

  • -f, --filter <type> - Filter by resource type
  • -l, --limit <number> - Limit number of results (default: 20)

Example:

x402 discover --filter api --limit 10

x402 info <url>

Get payment info without paying.

Options:

  • -v, --verbose - Show full payment requirements JSON

Example:

x402 info https://api.example.com/premium --verbose

x402 verify <txHash>

Check if a transaction was an x402 payment.

Options:

  • -n, --network <network> - Network to check (default: base-sepolia)

Example:

x402 verify 0x1234... --network base-mainnet

Configuration

Create a .env file in your working directory:

X402_PRIVATE_KEY=your_private_key_here
X402_FACILITATOR_URL=https://x402-facilitator.base.org

Development

# Install dependencies
npm install

# Run in development mode
npm run dev test https://example.com

# Build
npm run build

# Test locally
npm link
x402 --help

Contributing

PRs welcome. This is meant to make testing x402 endpoints easier.

License

MIT

About

CLI tool for x402 protocol interactions

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published