CLI for testing x402 payment endpoints.
- Test x402 endpoints and make payments
- Discover available x402 endpoints
- Check payment requirements without paying
- Verify transactions on-chain
npm install -g x402-cliOr use directly with npx:
npx x402-cli <command>Check what an endpoint accepts:
x402 info https://api.example.com/resourceFind available x402 APIs:
x402 discoverTest paying for something:
x402 test https://api.example.com/resource --key YOUR_PRIVATE_KEYTest 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 --verboseFind 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 10Get payment info without paying.
Options:
-v, --verbose- Show full payment requirements JSON
Example:
x402 info https://api.example.com/premium --verboseCheck if a transaction was an x402 payment.
Options:
-n, --network <network>- Network to check (default: base-sepolia)
Example:
x402 verify 0x1234... --network base-mainnetCreate a .env file in your working directory:
X402_PRIVATE_KEY=your_private_key_here
X402_FACILITATOR_URL=https://x402-facilitator.base.org# Install dependencies
npm install
# Run in development mode
npm run dev test https://example.com
# Build
npm run build
# Test locally
npm link
x402 --helpPRs welcome. This is meant to make testing x402 endpoints easier.
MIT