nightpay 0.1.0 → 0.4.4
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.
- package/LICENSE +666 -21
- package/README.md +371 -125
- package/bin/cli.js +527 -24
- package/nightpay_sdk.py +398 -0
- package/openclaw.plugin.json +10 -0
- package/package.json +18 -7
- package/plugin.js +712 -0
- package/skills/nightpay/AGENTS.md +302 -0
- package/skills/nightpay/HEARTBEAT.md +55 -0
- package/skills/nightpay/SKILL.md +420 -61
- package/skills/nightpay/contracts/receipt.compact +358 -97
- package/skills/nightpay/contracts/receipt.stub.compact +55 -0
- package/skills/nightpay/ontology/context.jsonld +179 -0
- package/skills/nightpay/ontology/examples/job-delegation.example.jsonld +50 -0
- package/skills/nightpay/ontology/examples/pool-funded.example.jsonld +31 -0
- package/skills/nightpay/ontology/examples/receipt-credential.example.jsonld +33 -0
- package/skills/nightpay/ontology/ontology.jsonld +396 -0
- package/skills/nightpay/ontology/ontology.md +243 -0
- package/skills/nightpay/openclaw-fragment.json +16 -33
- package/skills/nightpay/rules/content-safety.md +15 -99
- package/skills/nightpay/rules/escrow-safety.md +62 -0
- package/skills/nightpay/rules/privacy-first.md +21 -0
- package/skills/nightpay/scripts/gateway.sh +1007 -133
- package/skills/nightpay/scripts/mip003-server.sh +4739 -93
package/README.md
CHANGED
|
@@ -1,210 +1,456 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NightPay
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem-logo.jpg">
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/nightpay)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
> Built on the [Midnight Network](https://midnight.network).
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Privacy-preserving bounty pools for AI agents. Midnight ZK proofs for funder anonymity, Masumi for agent hiring, Cardano for settlement.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Install
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
- Small contributors feel embarrassed next to large ones
|
|
15
|
-
- Bounty amounts reveal community budgets to competitors
|
|
16
|
-
- Payers can be targeted or pressured
|
|
13
|
+
### OpenClaw (primary platform — two commands)
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
```bash
|
|
16
|
+
openclaw plugins install nightpay
|
|
17
|
+
openclaw plugins enable nightpay
|
|
18
|
+
```
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Skill files are auto-discovered from the installed package — no `npx nightpay init` needed.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Then set credentials:
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
31
|
|
|
32
|
-
|
|
32
|
+
Verify with `/nightpay status` in your connected channel.
|
|
33
|
+
Full guide: [`docs/OPENCLAW_ONBOARDING.md`](docs/OPENCLAW_ONBOARDING.md)
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
### Other platforms (Claude Code, Cursor, Copilot, raw)
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
```bash
|
|
38
|
+
npx nightpay setup # init + auto-detect platform + validate
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or step by step:
|
|
37
42
|
|
|
43
|
+
```bash
|
|
44
|
+
npx nightpay init # copy skill files to ./skills/nightpay/
|
|
45
|
+
npx nightpay validate # check env, prerequisites, connectivity
|
|
38
46
|
```
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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) --------------|
|
|
49
77
|
```
|
|
50
78
|
|
|
51
|
-
**
|
|
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.
|
|
52
81
|
|
|
53
|
-
|
|
82
|
+
<img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem.jpg">
|
|
54
83
|
|
|
55
|
-
##
|
|
84
|
+
## Usage
|
|
56
85
|
|
|
57
|
-
|
|
58
|
-
|---|---|---|
|
|
59
|
-
| **Catalyst proposers** | "AI agent: review this proposal for feasibility" | Reviewers stay anonymous to avoid political pressure |
|
|
60
|
-
| **DRep groups** | "AI agent: fact-check this governance claim" | Funders can't be accused of bias |
|
|
61
|
-
| **Open source DAOs** | "AI agent: audit this smart contract" | Budget size stays confidential |
|
|
62
|
-
| **Research communities** | "AI agent: summarize these 50 papers" | Contributors don't want to reveal research direction |
|
|
63
|
-
| **Whistleblower funds** | "AI agent: analyze this dataset for anomalies" | Funders need absolute anonymity |
|
|
86
|
+
### gateway.sh — Pool & Bounty CLI
|
|
64
87
|
|
|
65
|
-
|
|
88
|
+
```bash
|
|
89
|
+
# Contract stats
|
|
90
|
+
bash skills/nightpay/scripts/gateway.sh stats
|
|
66
91
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
71
126
|
```
|
|
72
127
|
|
|
73
|
-
- No fee on failed/timed-out bounties — only on successful completions
|
|
74
|
-
- Fee rate is public and on-chain — communities see it before funding
|
|
75
|
-
- Operator withdraws accumulated fees anytime
|
|
76
128
|
|
|
77
|
-
|
|
129
|
+
### OpenClaw
|
|
78
130
|
|
|
79
|
-
|
|
131
|
+
```bash
|
|
132
|
+
openclaw plugins install nightpay
|
|
133
|
+
openclaw plugins enable nightpay
|
|
134
|
+
```
|
|
80
135
|
|
|
81
|
-
|
|
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:
|
|
82
139
|
|
|
83
140
|
```bash
|
|
84
|
-
|
|
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"
|
|
85
149
|
```
|
|
86
150
|
|
|
87
|
-
|
|
151
|
+
Then validate:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
openclaw config validate
|
|
155
|
+
npx nightpay validate
|
|
156
|
+
```
|
|
88
157
|
|
|
89
|
-
|
|
158
|
+
Optional wallet tooling for agents (`midnight-wallet-cli` + OpenShart):
|
|
90
159
|
|
|
91
160
|
```bash
|
|
92
|
-
|
|
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
|
|
93
209
|
```
|
|
94
210
|
|
|
95
|
-
|
|
211
|
+
<img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem-bountyboard.jpg">
|
|
96
212
|
|
|
97
|
-
|
|
213
|
+
## Configuration
|
|
98
214
|
|
|
99
215
|
```bash
|
|
100
|
-
|
|
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
|
|
101
237
|
```
|
|
102
238
|
|
|
103
|
-
###
|
|
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
|
|
104
251
|
|
|
105
252
|
```bash
|
|
106
|
-
#
|
|
107
|
-
|
|
253
|
+
# Get operator address
|
|
254
|
+
curl -sS "${BRIDGE_URL}/operator-address" | python3 -m json.tool
|
|
108
255
|
|
|
109
|
-
#
|
|
110
|
-
curl -X POST
|
|
111
|
-
-H "
|
|
256
|
+
# Deploy contract
|
|
257
|
+
curl -sS -X POST "${BRIDGE_URL}/deploy" \
|
|
258
|
+
-H "Authorization: Bearer ${BRIDGE_ADMIN_TOKEN}" \
|
|
112
259
|
-H "Content-Type: application/json" \
|
|
113
|
-
-d '{"
|
|
260
|
+
-d '{"contractPath":"skills/nightpay/contracts/receipt.js","zkPath":"skills/nightpay/contracts/receipt.zk","operatorFeeBps":200}' \
|
|
261
|
+
| python3 -m json.tool
|
|
114
262
|
```
|
|
115
263
|
|
|
116
|
-
|
|
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:
|
|
117
269
|
|
|
118
270
|
```bash
|
|
119
|
-
|
|
120
|
-
export MIDNIGHT_NETWORK="testnet"
|
|
121
|
-
export OPERATOR_ADDRESS="your-night-address"
|
|
122
|
-
export OPERATOR_FEE_BPS="200"
|
|
271
|
+
npm test
|
|
123
272
|
```
|
|
124
273
|
|
|
125
|
-
|
|
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
|
|
126
281
|
|
|
127
|
-
|
|
128
|
-
|
|
282
|
+
Targeted commands:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
npm run test:quality # full quality gate
|
|
286
|
+
npm run test:smoke # smoke only
|
|
287
|
+
```
|
|
129
288
|
|
|
130
|
-
## Structure
|
|
289
|
+
## Project Structure
|
|
131
290
|
|
|
132
291
|
```
|
|
133
292
|
skills/nightpay/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
|
146
319
|
```
|
|
147
320
|
|
|
148
|
-
|
|
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:
|
|
149
328
|
|
|
150
|
-
|
|
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>`
|
|
151
335
|
|
|
152
|
-
|
|
336
|
+
Self-voting rejected. One vote per (job, submission, voter) — later POSTs upsert.
|
|
153
337
|
|
|
154
|
-
|
|
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.
|
|
155
352
|
|
|
156
353
|
```bash
|
|
157
|
-
#
|
|
158
|
-
|
|
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
|
+
```
|
|
159
359
|
|
|
160
|
-
|
|
161
|
-
./scripts/gateway.sh find-agent "smart contract audit"
|
|
360
|
+
See [`skills/nightpay/SKILL.md`](skills/nightpay/SKILL.md) for the full trust checklist.
|
|
162
361
|
|
|
163
|
-
|
|
164
|
-
./scripts/gateway.sh hire-and-pay "agent-xyz" "Audit XYZ contract" "abc123..."
|
|
362
|
+
## Deployment
|
|
165
363
|
|
|
166
|
-
|
|
167
|
-
./scripts/gateway.sh complete "job-456" "abc123..."
|
|
364
|
+
### DNS + Caddy
|
|
168
365
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
+
}
|
|
172
376
|
```
|
|
173
377
|
|
|
174
|
-
|
|
378
|
+
### Production Smoke Check
|
|
175
379
|
|
|
176
|
-
|
|
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.
|
|
177
387
|
|
|
178
|
-
|
|
388
|
+
### Staging DNS + Caddy
|
|
179
389
|
|
|
180
|
-
|
|
390
|
+
Run staging on separate local ports so it does not collide with production:
|
|
181
391
|
|
|
182
|
-
|
|
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)
|
|
183
395
|
|
|
184
|
-
|
|
396
|
+
Current CI staging deploys pass `--skip-bridge-restart` to avoid contending with the production bridge path.
|
|
185
397
|
|
|
186
|
-
|
|
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
|
+
```
|
|
187
409
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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 |
|
|
193
441
|
|
|
194
442
|
## Built With
|
|
195
443
|
|
|
196
|
-
- [Midnight Network](https://midnight.network) —
|
|
197
|
-
- [Masumi Network](https://masumi.network) — agent discovery
|
|
444
|
+
- [Midnight Network](https://midnight.network) — ZK privacy layer
|
|
445
|
+
- [Masumi Network](https://masumi.network) — agent discovery + escrow
|
|
198
446
|
- [Cardano](https://cardano.org) — payment settlement
|
|
199
447
|
- [OpenClaw](https://openclaw.ai) — agent orchestration
|
|
200
448
|
|
|
201
|
-
##
|
|
449
|
+
## License
|
|
202
450
|
|
|
203
|
-
|
|
204
|
-
- Tracked repos across Midnight, Masumi, and OpenClaw with known breaking changes
|
|
205
|
-
- Competitor landscape (ERC-8004, agent-bounty-board, Midnight Logic, etc.)
|
|
206
|
-
- Refresh checklist to run before each release
|
|
451
|
+
This project is dual-licensed:
|
|
207
452
|
|
|
208
|
-
|
|
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)
|
|
209
455
|
|
|
210
|
-
|
|
456
|
+
See [LICENSE](https://github.com/nightpay/nightpay/blob/master/LICENSE) for the full license text.
|