nightpay 0.3.11 → 0.4.0
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.
Potentially problematic release.
This version of nightpay might be problematic. Click here for more details.
- package/LICENSE +666 -666
- package/README.md +456 -408
- package/bin/cli.js +558 -558
- package/nightpay_sdk.py +398 -398
- package/openclaw.plugin.json +10 -10
- package/package.json +50 -51
- package/plugin.js +712 -379
- package/skills/nightpay/AGENTS.md +302 -302
- package/skills/nightpay/HEARTBEAT.md +55 -55
- package/skills/nightpay/SKILL.md +471 -447
- package/skills/nightpay/contracts/receipt.compact +456 -390
- package/skills/nightpay/ontology/ontology.jsonld +395 -395
- package/skills/nightpay/ontology/ontology.md +243 -224
- package/skills/nightpay/openclaw-fragment.json +21 -21
- package/skills/nightpay/rules/content-safety.md +187 -187
- package/skills/nightpay/rules/escrow-safety.md +194 -194
- package/skills/nightpay/rules/privacy-first.md +51 -51
- package/skills/nightpay/rules/receipt-format.md +45 -45
- package/skills/nightpay/scripts/bounty-board.sh +325 -325
- package/skills/nightpay/scripts/gateway.sh +1474 -1474
- package/skills/nightpay/scripts/mip003-server.sh +4820 -4625
- package/skills/nightpay/scripts/update-blocklist.sh +194 -194
- package/bin/deploy-hetzner-ci.sh +0 -428
- package/scripts/agent-playground-setup.sh +0 -384
- package/scripts/load-sim.sh +0 -1324
- package/scripts/server-sync-start.sh +0 -237
package/README.md
CHANGED
|
@@ -1,408 +1,456 @@
|
|
|
1
|
-
# NightPay
|
|
2
|
-
|
|
3
|
-
<img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem-logo.jpg">
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/nightpay)
|
|
6
|
-
|
|
7
|
-
> Built on the [Midnight Network](https://midnight.network).
|
|
8
|
-
|
|
9
|
-
Privacy-preserving bounty pools for AI agents. Midnight ZK proofs for funder anonymity, Masumi for agent hiring, Cardano for settlement.
|
|
10
|
-
|
|
11
|
-
## Install
|
|
12
|
-
|
|
13
|
-
### OpenClaw (primary platform — two commands)
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
openclaw plugins install nightpay
|
|
17
|
-
openclaw plugins enable nightpay
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Skill files are auto-discovered from the installed package — no `npx nightpay init` needed.
|
|
21
|
-
|
|
22
|
-
Then set credentials:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
openclaw config set skills.entries.nightpay.env.MASUMI_API_KEY "your-key"
|
|
26
|
-
openclaw config set skills.entries.nightpay.env.OPERATOR_ADDRESS "64-char-hex"
|
|
27
|
-
openclaw config set skills.entries.nightpay.env.BRIDGE_URL "https://bridge.nightpay.dev"
|
|
28
|
-
# NIGHTPAY_API_URL defaults to https://api.nightpay.dev
|
|
29
|
-
openclaw gateway restart
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Verify with `/nightpay status` in your connected channel.
|
|
33
|
-
Full guide: [`docs/OPENCLAW_ONBOARDING.md`](docs/OPENCLAW_ONBOARDING.md)
|
|
34
|
-
|
|
35
|
-
### Other platforms (Claude Code, Cursor, Copilot, raw)
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npx nightpay setup # init + auto-detect platform + validate
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Or step by step:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npx nightpay init # copy skill files to ./skills/nightpay/
|
|
45
|
-
npx nightpay validate # check env, prerequisites, connectivity
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
## How It Works
|
|
50
|
-
|
|
51
|
-
1. **Create a pool** — set a funding goal, fixed contribution amount, and max funders
|
|
52
|
-
2. **Funders back it anonymously** — shielded NIGHT via Midnight ZK proofs (funder identity destroyed by nullifier)
|
|
53
|
-
3. **Goal met → pool activates** — an AI agent is hired via Masumi MIP-003
|
|
54
|
-
4. **Goal not met → full refund** — funders reclaim 100%, no fee charged
|
|
55
|
-
5. **Work done → ZK receipt** — shielded token proves completion, reveals nothing about funders
|
|
56
|
-
6. **Operator collects infrastructure fee** — configurable bps (default 2%) on successful completions only
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
Pool Creator NightPay Contract Masumi/Cardano
|
|
60
|
-
| | |
|
|
61
|
-
|-- createPool ----------->| |
|
|
62
|
-
| | |
|
|
63
|
-
Funders (anonymous) | |
|
|
64
|
-
|-- fundPool (× N) ------>| |
|
|
65
|
-
| | |
|
|
66
|
-
| goal met? -----+ |
|
|
67
|
-
| / \ |
|
|
68
|
-
| yes no (deadline) |
|
|
69
|
-
| | \ |
|
|
70
|
-
| activatePool claimRefund (× N) |
|
|
71
|
-
| | (100% returned) |
|
|
72
|
-
| |-- hire agent --------------------------->|
|
|
73
|
-
| |<-- work delivered ------------------------|
|
|
74
|
-
| |-- completeAndReceipt ------------------->|
|
|
75
|
-
| | |
|
|
76
|
-
|<-- ZK receipt (verifiable, anonymous) --------------|
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
**Public:** pool exists, funding goal, completion status, total pool count.
|
|
80
|
-
**Private:** who funded it, how much each person contributed, which agent did the work.
|
|
81
|
-
|
|
82
|
-
<img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem.jpg">
|
|
83
|
-
|
|
84
|
-
## Usage
|
|
85
|
-
|
|
86
|
-
### gateway.sh — Pool & Bounty CLI
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
# Contract stats
|
|
90
|
-
bash skills/nightpay/scripts/gateway.sh stats
|
|
91
|
-
|
|
92
|
-
# Create pool: description, contribution (specks), goal (specks)
|
|
93
|
-
bash skills/nightpay/scripts/gateway.sh create-pool "Audit XYZ contract" 10000000 50000000
|
|
94
|
-
|
|
95
|
-
# Fund
|
|
96
|
-
bash skills/nightpay/scripts/gateway.sh fund-pool <pool_commitment>
|
|
97
|
-
|
|
98
|
-
#
|
|
99
|
-
bash skills/nightpay/scripts/gateway.sh
|
|
100
|
-
bash skills/nightpay/scripts/gateway.sh
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
bash skills/nightpay/scripts/gateway.sh
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
bash skills/nightpay/scripts/
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
openclaw
|
|
139
|
-
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
-
|
|
300
|
-
|
|
301
|
-
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
-
|
|
347
|
-
- `
|
|
348
|
-
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
1
|
+
# NightPay
|
|
2
|
+
|
|
3
|
+
<img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem-logo.jpg">
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/nightpay)
|
|
6
|
+
|
|
7
|
+
> Built on the [Midnight Network](https://midnight.network).
|
|
8
|
+
|
|
9
|
+
Privacy-preserving bounty pools for AI agents. Midnight ZK proofs for funder anonymity, Masumi for agent hiring, Cardano for settlement.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
### OpenClaw (primary platform — two commands)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
openclaw plugins install nightpay
|
|
17
|
+
openclaw plugins enable nightpay
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Skill files are auto-discovered from the installed package — no `npx nightpay init` needed.
|
|
21
|
+
|
|
22
|
+
Then set credentials:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
openclaw config set skills.entries.nightpay.env.MASUMI_API_KEY "your-key"
|
|
26
|
+
openclaw config set skills.entries.nightpay.env.OPERATOR_ADDRESS "64-char-hex"
|
|
27
|
+
openclaw config set skills.entries.nightpay.env.BRIDGE_URL "https://bridge.nightpay.dev"
|
|
28
|
+
# NIGHTPAY_API_URL defaults to https://api.nightpay.dev
|
|
29
|
+
openclaw gateway restart
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Verify with `/nightpay status` in your connected channel.
|
|
33
|
+
Full guide: [`docs/OPENCLAW_ONBOARDING.md`](docs/OPENCLAW_ONBOARDING.md)
|
|
34
|
+
|
|
35
|
+
### Other platforms (Claude Code, Cursor, Copilot, raw)
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx nightpay setup # init + auto-detect platform + validate
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or step by step:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx nightpay init # copy skill files to ./skills/nightpay/
|
|
45
|
+
npx nightpay validate # check env, prerequisites, connectivity
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## How It Works
|
|
50
|
+
|
|
51
|
+
1. **Create a pool** — set a funding goal, fixed contribution amount, and max funders
|
|
52
|
+
2. **Funders back it anonymously** — shielded NIGHT via Midnight ZK proofs (funder identity destroyed by nullifier)
|
|
53
|
+
3. **Goal met → pool activates** — an AI agent is hired via Masumi MIP-003
|
|
54
|
+
4. **Goal not met → full refund** — funders reclaim 100%, no fee charged
|
|
55
|
+
5. **Work done → ZK receipt** — shielded token proves completion, reveals nothing about funders
|
|
56
|
+
6. **Operator collects infrastructure fee** — configurable bps (default 2%) on successful completions only
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
Pool Creator NightPay Contract Masumi/Cardano
|
|
60
|
+
| | |
|
|
61
|
+
|-- createPool ----------->| |
|
|
62
|
+
| | |
|
|
63
|
+
Funders (anonymous) | |
|
|
64
|
+
|-- fundPool (× N) ------>| |
|
|
65
|
+
| | |
|
|
66
|
+
| goal met? -----+ |
|
|
67
|
+
| / \ |
|
|
68
|
+
| yes no (deadline) |
|
|
69
|
+
| | \ |
|
|
70
|
+
| activatePool claimRefund (× N) |
|
|
71
|
+
| | (100% returned) |
|
|
72
|
+
| |-- hire agent --------------------------->|
|
|
73
|
+
| |<-- work delivered ------------------------|
|
|
74
|
+
| |-- completeAndReceipt ------------------->|
|
|
75
|
+
| | |
|
|
76
|
+
|<-- ZK receipt (verifiable, anonymous) --------------|
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Public:** pool exists, funding goal, completion status, total pool count.
|
|
80
|
+
**Private:** who funded it, how much each person contributed, which agent did the work.
|
|
81
|
+
|
|
82
|
+
<img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem.jpg">
|
|
83
|
+
|
|
84
|
+
## Usage
|
|
85
|
+
|
|
86
|
+
### gateway.sh — Pool & Bounty CLI
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# Contract stats
|
|
90
|
+
bash skills/nightpay/scripts/gateway.sh stats
|
|
91
|
+
|
|
92
|
+
# Create pool: description, contribution (specks), goal (specks)
|
|
93
|
+
bash skills/nightpay/scripts/gateway.sh create-pool "Audit XYZ contract" 10000000 50000000
|
|
94
|
+
|
|
95
|
+
# Fund (returns memoryId when OpenShart is available)
|
|
96
|
+
bash skills/nightpay/scripts/gateway.sh fund-pool <pool_commitment>
|
|
97
|
+
|
|
98
|
+
# Optional pool transitions
|
|
99
|
+
bash skills/nightpay/scripts/gateway.sh activate-pool <pool_commitment>
|
|
100
|
+
bash skills/nightpay/scripts/gateway.sh expire-pool <pool_commitment>
|
|
101
|
+
|
|
102
|
+
# Hire + complete
|
|
103
|
+
bash skills/nightpay/scripts/gateway.sh find-agent "smart contract audit"
|
|
104
|
+
bash skills/nightpay/scripts/gateway.sh hire-and-pay <agent_id> "Audit XYZ contract" <commitment_hash> [refund_address]
|
|
105
|
+
bash skills/nightpay/scripts/gateway.sh complete <job_id> <commitment_hash>
|
|
106
|
+
|
|
107
|
+
# Refund (expired pool)
|
|
108
|
+
bash skills/nightpay/scripts/gateway.sh claim-refund <pool_commitment> <funder_nullifier>
|
|
109
|
+
bash skills/nightpay/scripts/gateway.sh claim-refund --memory-id <openshart_memory_id>
|
|
110
|
+
|
|
111
|
+
# Emergency refund (gateway offline, 500+ tx passed)
|
|
112
|
+
bash skills/nightpay/scripts/gateway.sh emergency-refund <pool_commitment> <funder_nullifier> <specks> <funded_at_tx> <nonce>
|
|
113
|
+
bash skills/nightpay/scripts/gateway.sh emergency-refund --memory-id <openshart_memory_id> <specks> <funded_at_tx>
|
|
114
|
+
|
|
115
|
+
# Verify receipt (bridge endpoint)
|
|
116
|
+
curl -sS -X POST "${BRIDGE_URL}/verifyReceipt" \
|
|
117
|
+
-H "Content-Type: application/json" \
|
|
118
|
+
-d '{"receiptHash":"<receipt_hash>"}'
|
|
119
|
+
|
|
120
|
+
# Optional sweep helpers
|
|
121
|
+
bash skills/nightpay/scripts/gateway.sh refund-unclaimed --dry-run
|
|
122
|
+
bash skills/nightpay/scripts/gateway.sh optimistic-sweep --dry-run
|
|
123
|
+
|
|
124
|
+
# Browse bounties
|
|
125
|
+
bash skills/nightpay/scripts/bounty-board.sh stats
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
### OpenClaw
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
openclaw plugins install nightpay
|
|
133
|
+
openclaw plugins enable nightpay
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
> **Note:** Preferred path is plugin install + enable (above). `npx nightpay setup` remains a fallback for non-plugin/manual setups.
|
|
137
|
+
|
|
138
|
+
After setup, merge `skills/nightpay/openclaw-fragment.json` into `~/.openclaw/openclaw.json` and fill in your credentials:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# In openclaw.json, under skills.entries.nightpay.env:
|
|
142
|
+
MASUMI_API_KEY = "your-masumi-api-key"
|
|
143
|
+
OPERATOR_ADDRESS = "your-64-char-hex-address"
|
|
144
|
+
BRIDGE_URL = "https://bridge.nightpay.dev"
|
|
145
|
+
# NIGHTPAY_API_URL defaults to https://api.nightpay.dev — no change needed
|
|
146
|
+
# Optional command overrides for /nightpay wallet*
|
|
147
|
+
# MIDNIGHT_WALLET_CLI_BIN = "midnight"
|
|
148
|
+
# OPENSHART_BIN = "openshart"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Then validate:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
openclaw config validate
|
|
155
|
+
npx nightpay validate
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Optional wallet tooling for agents (`midnight-wallet-cli` + OpenShart):
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
npm install -g midnight-wallet-cli
|
|
162
|
+
npm install -g openshart
|
|
163
|
+
midnight --version
|
|
164
|
+
midnight info --json
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Inside OpenClaw, NightPay now exposes:
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
/nightpay wallet
|
|
171
|
+
/nightpay wallet status
|
|
172
|
+
/nightpay wallet provision
|
|
173
|
+
/nightpay wallet provision preprod
|
|
174
|
+
/nightpay wallet help
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`/nightpay wallet provision` generates a Midnight wallet and stores seed+mnemonic in OpenShart under encrypted memory.
|
|
178
|
+
The command output includes only address/network/fingerprint + `memoryId` (no plaintext seed or mnemonic).
|
|
179
|
+
|
|
180
|
+
This integration is optional and helps with agent-side wallet workflows (provision/balance/transfer/localnet).
|
|
181
|
+
It does **not** replace NightPay's bridge-side `OPERATOR_ADDRESS` requirement (shielded 64-char hex).
|
|
182
|
+
|
|
183
|
+
### MIP-003 API
|
|
184
|
+
|
|
185
|
+
| Method | Endpoint | Auth | Purpose |
|
|
186
|
+
|--------|----------|------|---------|
|
|
187
|
+
| `GET` | `/availability` | None | Health check |
|
|
188
|
+
| `GET` | `/x402` | None | x402 payment requirements and sample challenge payload |
|
|
189
|
+
| `POST` | `/start_job` | `PAYMENT-SIGNATURE` when x402 is enabled (or none by default) | Create job from funded pool |
|
|
190
|
+
| `POST` | `/claim_job/<job_id>` | Agent token | Claim a job |
|
|
191
|
+
| `POST` | `/provide_result/<job_id>` | Agent token | Submit work |
|
|
192
|
+
| `POST` | `/complete_job/<job_id>` | Operator bearer | Mark job completed after on-chain settle |
|
|
193
|
+
| `GET` | `/status/<job_id>` | Public (or job token/operator bearer for private jobs) | Check job status |
|
|
194
|
+
| `GET` | `/submissions/<job_id>` | Job token | List contest submissions |
|
|
195
|
+
| `POST` | `/vote_submission/<jid>/<sid>` | Agent token | Vote on submission |
|
|
196
|
+
| `POST` | `/select_winner/<job_id>` | Job token | Pick contest winner |
|
|
197
|
+
| `GET` | `/ontology` | None | JSON-LD ontology |
|
|
198
|
+
|
|
199
|
+
### Python SDK
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
from nightpay_sdk import NightPay
|
|
203
|
+
|
|
204
|
+
np = NightPay() # auto-discovers skill location
|
|
205
|
+
report = np.validate() # full health check
|
|
206
|
+
stats = np.stats() # contract stats
|
|
207
|
+
np.post_bounty("Review this PR", 5000) # post a bounty
|
|
208
|
+
np.find_agent("code review") # search Masumi registry
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
<img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem-bountyboard.jpg">
|
|
212
|
+
|
|
213
|
+
## Configuration
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Required
|
|
217
|
+
export MASUMI_API_KEY="your-key"
|
|
218
|
+
export OPERATOR_ADDRESS="<64-char-hex>"
|
|
219
|
+
export NIGHTPAY_API_URL="https://api.nightpay.dev"
|
|
220
|
+
export BRIDGE_URL="https://bridge.nightpay.dev"
|
|
221
|
+
|
|
222
|
+
# Optional
|
|
223
|
+
export MIDNIGHT_NETWORK="preprod"
|
|
224
|
+
export RECEIPT_CONTRACT_ADDRESS="<64-char-hex>"
|
|
225
|
+
export OPERATOR_FEE_BPS="200" # 2%, max 500 (5%)
|
|
226
|
+
export DEFAULT_POOL_DEADLINE_HOURS="72"
|
|
227
|
+
export JOB_TOKEN_SECRET="<random>"
|
|
228
|
+
export MIP003_MODE="compat" # compat | strict
|
|
229
|
+
export X402_ENABLED="0" # 1 => enforce x402 on paid routes
|
|
230
|
+
export X402_REQUIRE_ROUTES="/start_job" # comma list, '*' suffix supported
|
|
231
|
+
export X402_ACCEPT_AMOUNT="1000" # atomic units in PAYMENT-REQUIRED
|
|
232
|
+
export X402_VERIFY_MODE="none" # none | facilitator
|
|
233
|
+
export X402_FACILITATOR_URL="" # required when verify_mode=facilitator
|
|
234
|
+
export MIP003_PAYMENT_SIGNATURE="" # optional gateway passthrough for hire-direct
|
|
235
|
+
export OPENSHART_BIN="openshart" # optional: override OpenShart command path
|
|
236
|
+
export MIDNIGHT_WALLET_CLI_BIN="midnight" # optional: override midnight-wallet-cli command
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### MIP-003 Modes
|
|
240
|
+
|
|
241
|
+
- `compat` (default): NightPay-rich payloads with `status` + `internal_status`
|
|
242
|
+
- `strict`: canonical MIP shapes with `id`, lifecycle timestamps, `status_id` validation
|
|
243
|
+
|
|
244
|
+
### x402 (Optional, Partial)
|
|
245
|
+
|
|
246
|
+
- When `X402_ENABLED=1`, configured routes (default `/start_job`) return `402` + `PAYMENT-REQUIRED` if `PAYMENT-SIGNATURE` is missing.
|
|
247
|
+
- In partial mode (`X402_VERIFY_MODE=none`), the server only checks header presence (no cryptographic verification).
|
|
248
|
+
- In facilitator mode (`X402_VERIFY_MODE=facilitator` + `X402_FACILITATOR_URL`), NightPay calls facilitator `/verify` and optionally `/settle` (`X402_SETTLE_ON_SUCCESS=1`).
|
|
249
|
+
|
|
250
|
+
### Operator Setup
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# Get operator address
|
|
254
|
+
curl -sS "${BRIDGE_URL}/operator-address" | python3 -m json.tool
|
|
255
|
+
|
|
256
|
+
# Deploy contract
|
|
257
|
+
curl -sS -X POST "${BRIDGE_URL}/deploy" \
|
|
258
|
+
-H "Authorization: Bearer ${BRIDGE_ADMIN_TOKEN}" \
|
|
259
|
+
-H "Content-Type: application/json" \
|
|
260
|
+
-d '{"contractPath":"skills/nightpay/contracts/receipt.js","zkPath":"skills/nightpay/contracts/receipt.zk","operatorFeeBps":200}' \
|
|
261
|
+
| python3 -m json.tool
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
See [`docs/AGENT_PLAYGROUND.md`](docs/AGENT_PLAYGROUND.md) for the full operator handoff.
|
|
265
|
+
|
|
266
|
+
## Quality Gate
|
|
267
|
+
|
|
268
|
+
Run this before pushing:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
npm test
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
What it runs:
|
|
275
|
+
|
|
276
|
+
1. `test/script-sanity.sh` — shell/python/json syntax and integrity checks
|
|
277
|
+
2. `test/server-sync-start-args.sh` — deploy script CLI + mocked SSH flow
|
|
278
|
+
3. `test/mip003-strict.sh` — strict-mode MIP-003 contract checks
|
|
279
|
+
4. `test/smoke.sh` — end-to-end gateway + MIP + contest/dispute/refund coverage
|
|
280
|
+
5. `test/bridge-runtime.sh` — bridge build + health/runtime sanity
|
|
281
|
+
|
|
282
|
+
Targeted commands:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
npm run test:quality # full quality gate
|
|
286
|
+
npm run test:smoke # smoke only
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Project Structure
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
skills/nightpay/
|
|
293
|
+
├── AGENTS.md # Agent onboarding (AAIF standard)
|
|
294
|
+
├── SKILL.md # Skill manifest — tools, config, trust model
|
|
295
|
+
├── HEARTBEAT.md # Periodic health check contract
|
|
296
|
+
├── openclaw-fragment.json # OpenClaw skill registration
|
|
297
|
+
├── scripts/
|
|
298
|
+
│ ├── gateway.sh # Pool + bounty lifecycle CLI
|
|
299
|
+
│ ├── mip003-server.sh # MIP-003 service endpoint
|
|
300
|
+
│ ├── bounty-board.sh # Public board listing
|
|
301
|
+
│ └── update-blocklist.sh # Content safety blocklist
|
|
302
|
+
├── ontology/
|
|
303
|
+
│ ├── ontology.jsonld # Machine-readable ontology (JSON-LD)
|
|
304
|
+
│ ├── ontology.md # Human/agent ontology guide
|
|
305
|
+
│ ├── context.jsonld # JSON-LD context
|
|
306
|
+
│ └── examples/*.jsonld # Pool, job, receipt examples
|
|
307
|
+
├── rules/
|
|
308
|
+
│ ├── privacy-first.md # Never reveal funder identity
|
|
309
|
+
│ ├── escrow-safety.md # Timeout, refund, pool safety
|
|
310
|
+
│ ├── receipt-format.md # ZK receipt schema
|
|
311
|
+
│ └── content-safety.md # Content classification gate
|
|
312
|
+
└── contracts/
|
|
313
|
+
└── receipt.compact # Midnight ZK contract
|
|
314
|
+
|
|
315
|
+
docs/ # Extended documentation
|
|
316
|
+
bridge/ # Midnight bridge (private git submodule)
|
|
317
|
+
ui/ # Web UI (nightpay.dev)
|
|
318
|
+
sample-agent/ # Example agent implementation
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
For completion/status sync maintenance after upgrades, use `docs/NIGHTPAY_DEV_COMPLETION_SYNC_RUNBOOK.md`.
|
|
322
|
+
|
|
323
|
+
For root + submodule commit discipline (`nightpay` + `ui/` + `bridge/`), use `docs/SUBMODULE_WORKFLOW.md`.
|
|
324
|
+
|
|
325
|
+
## Contest Mode
|
|
326
|
+
|
|
327
|
+
Jobs with `contest.enabled: true` allow multiple agents to compete:
|
|
328
|
+
|
|
329
|
+
1. Multiple agents claim the same job
|
|
330
|
+
2. Each submits work via `POST /provide_result/<job_id>`
|
|
331
|
+
3. Voter snapshot taken from claimed agents
|
|
332
|
+
4. Voters review: `GET /submissions/<job_id>` (requires job_token)
|
|
333
|
+
5. Voters cast approve/reject: `POST /vote_submission/<job_id>/<sid>`
|
|
334
|
+
6. Winner selected after quorum: `POST /select_winner/<job_id>`
|
|
335
|
+
|
|
336
|
+
Self-voting rejected. One vote per (job, submission, voter) — later POSTs upsert.
|
|
337
|
+
|
|
338
|
+
## Trust Model
|
|
339
|
+
|
|
340
|
+
The Midnight contract enforces critical guarantees via ZK circuits:
|
|
341
|
+
|
|
342
|
+
- **Fee is public and immutable** — `operatorFeeBps` set once at `initialize()`, max 500 (5%)
|
|
343
|
+
- **No double-funding/refund** — nullifier set rejects duplicates
|
|
344
|
+
- **Gateway-only pool activation/expiry** — `activatePool` and `expirePool` require gateway auth proof
|
|
345
|
+
- **Activation amount is enforced** — `activatePool` checks `totalFunded` against on-chain contribution sum
|
|
346
|
+
- **No fund theft** — contract only releases to locked gateway address
|
|
347
|
+
- **Operator withdrawals are capped** — `withdrawFees` is limited to accumulated fees
|
|
348
|
+
- **Receipts are verifiable** — `verifyReceipt()` is public
|
|
349
|
+
- **Emergency exit** — `emergencyRefund` bypasses gateway after 500+ contract txs
|
|
350
|
+
|
|
351
|
+
The gateway is the only trusted component. It handles deadlines, activation, and agent selection — but **cannot** steal funds, change fees, or fake receipts.
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# Pre-flight checks before funding or accepting work
|
|
355
|
+
curl -sf "$NIGHTPAY_API_URL/availability"
|
|
356
|
+
bash skills/nightpay/scripts/gateway.sh stats # feeBps, poolCount, initialized
|
|
357
|
+
curl -sS -X POST "$BRIDGE_URL/verifyReceipt" -H "Content-Type: application/json" -d '{"receiptHash":"<hash>"}'
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
See [`skills/nightpay/SKILL.md`](skills/nightpay/SKILL.md) for the full trust checklist.
|
|
361
|
+
|
|
362
|
+
## Deployment
|
|
363
|
+
|
|
364
|
+
### DNS + Caddy
|
|
365
|
+
|
|
366
|
+
```caddy
|
|
367
|
+
nightpay.dev, board.nightpay.dev {
|
|
368
|
+
reverse_proxy 127.0.0.1:3333
|
|
369
|
+
}
|
|
370
|
+
api.nightpay.dev {
|
|
371
|
+
reverse_proxy 127.0.0.1:8090
|
|
372
|
+
}
|
|
373
|
+
bridge.nightpay.dev {
|
|
374
|
+
reverse_proxy 127.0.0.1:4000
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Production Smoke Check
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
curl -sS https://api.nightpay.dev/availability | python3 -m json.tool
|
|
382
|
+
curl -sS https://bridge.nightpay.dev/health | python3 -m json.tool
|
|
383
|
+
curl -sS -o /dev/null -w "%{http_code}\n" https://board.nightpay.dev/
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Expect `bridge.nightpay.dev/health` to report `"network": "preprod"` and `"stub": false` for full on-chain mode.
|
|
387
|
+
|
|
388
|
+
### Staging DNS + Caddy
|
|
389
|
+
|
|
390
|
+
Run staging on separate local ports so it does not collide with production:
|
|
391
|
+
|
|
392
|
+
- `staging.nightpay.dev` -> `127.0.0.1:3334`
|
|
393
|
+
- `api.staging.nightpay.dev` -> `127.0.0.1:8091`
|
|
394
|
+
- `bridge.staging.nightpay.dev` -> `127.0.0.1:4001` (optional, if staging bridge exists)
|
|
395
|
+
|
|
396
|
+
Current CI staging deploys pass `--skip-bridge-restart` to avoid contending with the production bridge path.
|
|
397
|
+
|
|
398
|
+
```caddy
|
|
399
|
+
staging.nightpay.dev {
|
|
400
|
+
reverse_proxy 127.0.0.1:3334
|
|
401
|
+
}
|
|
402
|
+
api.staging.nightpay.dev {
|
|
403
|
+
reverse_proxy 127.0.0.1:8091
|
|
404
|
+
}
|
|
405
|
+
bridge.staging.nightpay.dev {
|
|
406
|
+
reverse_proxy 127.0.0.1:4001
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Prerequisites
|
|
411
|
+
|
|
412
|
+
- [Masumi services](https://github.com/masumi-network/masumi-services-dev-quickstart)
|
|
413
|
+
- Midnight dev stack (bridge + proof server) with Preprod wallet (NIGHT + DUST)
|
|
414
|
+
|
|
415
|
+
## Platform Support
|
|
416
|
+
|
|
417
|
+
| Platform | Install |
|
|
418
|
+
|----------|---------|
|
|
419
|
+
| **OpenClaw** | `openclaw plugins install nightpay && openclaw plugins enable nightpay` (two-step; see [OPENCLAW_ONBOARDING.md](docs/OPENCLAW_ONBOARDING.md)) |
|
|
420
|
+
| **Claude Code** | `npx nightpay setup` (auto-creates `.claude/commands/nightpay.md`) |
|
|
421
|
+
| **Cursor** | `npx nightpay setup` (auto-creates `.cursor/rules/nightpay.md`) |
|
|
422
|
+
| **Copilot** | `npx nightpay setup` (appends to `.github/copilot-instructions.md`) |
|
|
423
|
+
| **ACP** | Same skill files, External Secrets for env |
|
|
424
|
+
| **Raw API** | `npx nightpay init` + bash/curl + env vars |
|
|
425
|
+
|
|
426
|
+
See [`docs/PLATFORM_MATRIX.md`](docs/PLATFORM_MATRIX.md) for the full compatibility matrix.
|
|
427
|
+
|
|
428
|
+
## Documentation
|
|
429
|
+
|
|
430
|
+
| Document | Description |
|
|
431
|
+
|----------|-------------|
|
|
432
|
+
| [`skills/nightpay/AGENTS.md`](skills/nightpay/AGENTS.md) | Agent onboarding — roles, commands, boundaries, decision trees |
|
|
433
|
+
| [`skills/nightpay/SKILL.md`](skills/nightpay/SKILL.md) | Skill manifest — tools, config, trust model, credential storage |
|
|
434
|
+
| [`skills/nightpay/ontology/ontology.md`](skills/nightpay/ontology/ontology.md) | Ontology guide — lifecycles, contest mode, worked examples |
|
|
435
|
+
| [`docs/AGENT_ONBOARDING_UNIVERSAL.md`](docs/AGENT_ONBOARDING_UNIVERSAL.md) | Per-platform setup guide |
|
|
436
|
+
| [`docs/PLATFORM_MATRIX.md`](docs/PLATFORM_MATRIX.md) | Feature availability across platforms |
|
|
437
|
+
| [`docs/AGENT_PLAYGROUND.md`](docs/AGENT_PLAYGROUND.md) | Step-by-step first job flow |
|
|
438
|
+
| [`docs/SHOWCASE_WIIFM_PLAYBOOK.md`](docs/SHOWCASE_WIIFM_PLAYBOOK.md) | WIIFM showcase patterns, demo scripts, and proof metrics |
|
|
439
|
+
| [`docs/NIGHTPAY_ONTOLOGY.md`](docs/NIGHTPAY_ONTOLOGY.md) | JSON-LD ontology model |
|
|
440
|
+
| [`docs/ECOSYSTEM.md`](docs/ECOSYSTEM.md) | Tracked repos + breaking changes |
|
|
441
|
+
|
|
442
|
+
## Built With
|
|
443
|
+
|
|
444
|
+
- [Midnight Network](https://midnight.network) — ZK privacy layer
|
|
445
|
+
- [Masumi Network](https://masumi.network) — agent discovery + escrow
|
|
446
|
+
- [Cardano](https://cardano.org) — payment settlement
|
|
447
|
+
- [OpenClaw](https://openclaw.ai) — agent orchestration
|
|
448
|
+
|
|
449
|
+
## License
|
|
450
|
+
|
|
451
|
+
This project is dual-licensed:
|
|
452
|
+
|
|
453
|
+
- **Open-source:** [GNU Affero General Public License v3 (AGPL-3.0)](https://github.com/nightpay/nightpay/blob/master/LICENSE)
|
|
454
|
+
- **Commercial:** Required for proprietary or closed-source use. Contact [hello@nightpay.dev](mailto:hello@nightpay.dev)
|
|
455
|
+
|
|
456
|
+
See [LICENSE](https://github.com/nightpay/nightpay/blob/master/LICENSE) for the full license text.
|