@lemmaoracle/x402 0.1.4 → 0.1.5

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 (2) hide show
  1. package/README.md +89 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # @lemmaoracle/x402
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@lemmaoracle/x402)](https://www.npmjs.com/package/@lemmaoracle/x402)
4
+ [![License](https://img.shields.io/npm/l/@lemmaoracle/x402)](https://github.com/lemmaoracle/lemmaoracle/blob/main/LICENSE)
5
+
6
+ Drop-in replacement for `@x402/*` with automatic [Lemma](https://lemma.frame00.com) discovery and zero-knowledge proof submission.
7
+
8
+ ## Overview
9
+
10
+ Switch your x402 imports from `@x402/*` to `@lemmaoracle/x402` and get automatic ZK proof generation on every settlement. The package adds Lemma discovery metadata and proof submission without changing your existing x402 integration code.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install @lemmaoracle/x402 @lemmaoracle/sdk
16
+ ```
17
+
18
+ > `@lemmaoracle/sdk` is a required peer dependency.
19
+
20
+ ## Quick Start
21
+
22
+ ```typescript
23
+ import { Hono } from "hono";
24
+ import {
25
+ HTTPFacilitatorClient,
26
+ x402ResourceServer,
27
+ paymentMiddleware,
28
+ ExactEvmScheme,
29
+ } from "@lemmaoracle/x402";
30
+
31
+ const app = new Hono();
32
+ const facilitator = new HTTPFacilitatorClient();
33
+
34
+ // Pass LemmaConfig to enable proof generation; omit to use as plain @x402/* wrapper
35
+ const server = new x402ResourceServer(facilitator, {
36
+ apiKey: "your-lemma-api-key",
37
+ discovery: { schemas: ["dev:document:v1"] },
38
+ });
39
+
40
+ app.use(
41
+ "/verify/:hash",
42
+ paymentMiddleware(
43
+ {
44
+ "GET /verify/:hash": {
45
+ price: "$0.01",
46
+ network: "base-sepolia",
47
+ resource: "verification-api",
48
+ scheme: ExactEvmScheme,
49
+ paysTo: "0xYourAddress",
50
+ },
51
+ },
52
+ server,
53
+ ),
54
+ );
55
+
56
+ app.get("/verify/:hash", async (c) => {
57
+ return c.json({ verified: true, hash: c.req.param("hash") });
58
+ });
59
+ ```
60
+
61
+ ## How it works
62
+
63
+ After each x402 settlement, the augmented `x402ResourceServer` automatically triggers a `onAfterSettle` hook that registers the payment as a Lemma document, generates a ZK proof via a Node.js relay, and submits the proof to the Lemma oracle. Proof data is included in the settlement response header.
64
+
65
+ ## Exports
66
+
67
+ **Re-exports from `@x402/*`** — `HTTPFacilitatorClient`, `ExactEvmScheme`, `x402Client`, plus associated types (`Network`, `PaymentRequirements`, `PaymentPayload`, `FacilitatorConfig`).
68
+
69
+ **Augmented exports** — `x402ResourceServer` (auto-attaches Lemma hook), `paymentMiddleware` (auto-enriches routes with discovery metadata).
70
+
71
+ **Advanced** (`@lemmaoracle/x402/advanced`) — `createLemmaSubmissionHandler`, `resolveDiscoveryConfig`, for custom orchestration. See `LemmaConfig` type for all configuration options.
72
+
73
+ ## ZK Circuit
74
+
75
+ This package includes a [Circom circuit](./circuits/README.md) (`circuits/payment.circom`) that generates a Groth16 proof of a valid x402 payment. Commitment: `Poseidon6(txHashLow, txHashHigh, recipientLow, amount, timestamp, minAmount)`.
76
+
77
+ ## Development
78
+
79
+ ```bash
80
+ pnpm install
81
+ pnpm build # compile TypeScript
82
+ pnpm build:circuit # build the Circom circuit
83
+ pnpm test # run tests
84
+ pnpm register # register circuit with Lemma (requires env vars)
85
+ ```
86
+
87
+ ## License
88
+
89
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemmaoracle/x402",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Drop-in replacement for @x402/* with automatic Lemma discovery and proof submission",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",