@mingderwang/x402 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +23 -2
  2. package/dist/cli.js +24596 -0
  3. package/package.json +6 -3
  4. package/src/cli.ts +342 -0
package/README.md CHANGED
@@ -2,12 +2,33 @@
2
2
 
3
3
  `HTTP 402 Payment Required` helpers for the [x402](https://github.com/x402-foundation/specs) standard — payment requirements, EIP-3009 signing, `X-PAYMENT`, verification, and on-chain settlement.
4
4
 
5
- Built on ethers v6 + `@mingderwang/wallet`.
5
+ Built on ethers v6 + `@mingderwang/wallet`. Ships both a library and an `x402` CLI.
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install @mingderwang/x402
10
+ npm install @mingderwang/x402 # library
11
+ npm install -g @mingderwang/x402 # also gives the `x402` CLI
12
+ ```
13
+
14
+ ## CLI
15
+
16
+ ```
17
+ x402 requirements <url> [--method GET] [--header K:V]...
18
+ x402 sign <requirements.json> [--wallet <keystore>]
19
+ x402 pay <url> [--method GET] [--header K:V]... [--wallet <keystore>]
20
+ x402 decode <base64-or-file | payload.json>
21
+ x402 verify <payload> <requirements.json>
22
+ x402 settle <payload> <requirements.json> [--gas-key <private>] [--rpc <url>]
23
+ ```
24
+
25
+ Keystore defaults to `~/.wallet/wallet.json` (create one with the `wallet` CLI). Password via prompt or `WALLET_PASSWORD` / `XSIFT_WALLET_PASSWORD` env. Full round trip:
26
+
27
+ ```bash
28
+ x402 requirements https://api.example.com/resource # shows the 402 + accepts[]
29
+ x402 pay https://api.example.com/resource # signs + pays + retries with X-PAYMENT
30
+ x402 verify <header> requirements.json # offline sanity check
31
+ x402 settle <payload.json> requirements.json --gas-key 0x... # broadcast on-chain
11
32
  ```
12
33
 
13
34
  ## Client side — detect a paywall and pay