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/README.md CHANGED
@@ -1,210 +1,456 @@
1
- # nightpay
1
+ # NightPay
2
2
 
3
- **Anonymous community bounties for AI agents.**
3
+ <img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem-logo.jpg">
4
4
 
5
- A community posts a bounty. An agent completes it. Everyone verifies. Nobody knows who funded it.
5
+ [![npm version](https://img.shields.io/npm/v/nightpay)](https://www.npmjs.com/package/nightpay)
6
6
 
7
- ## How Community Bounties Work Today (The Problem)
7
+ > Built on the [Midnight Network](https://midnight.network).
8
8
 
9
- A DAO wants a research report. A Catalyst group needs code reviewed. A DRep community wants fact-checking done by an AI agent.
9
+ Privacy-preserving bounty pools for AI agents. Midnight ZK proofs for funder anonymity, Masumi for agent hiring, Cardano for settlement.
10
10
 
11
- On Cardano + Masumi today, they can post a bounty and hire an agent — but **every community member's contribution is public**. Everyone sees who put in how much. That kills participation:
11
+ ## Install
12
12
 
13
- - Members don't want to be seen funding controversial research
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
- ## Why Not Just Use Midnight + Masumi Directly?
15
+ ```bash
16
+ openclaw plugins install nightpay
17
+ openclaw plugins enable nightpay
18
+ ```
19
19
 
20
- Midnight can do private transfers. Masumi can hire and pay agents. So why does nightpay exist?
20
+ Skill files are auto-discovered from the installed package no `npx nightpay init` needed.
21
21
 
22
- Because **none of them provide the community bounty board pattern**:
22
+ Then set credentials:
23
23
 
24
- | What You Need | What Exists Today | What NightPay Adds |
25
- |---|---|---|
26
- | **20 people fund one bounty** | Midnight does 1:1 transfers | Many-to-one anonymous pooling into a single bounty commitment |
27
- | **Nobody knows who funded what** | Midnight hides sender/receiver | Funder-to-bounty link is *destroyed* — even knowing Alice sent NIGHT, you can't prove she funded *this* bounty |
28
- | **Proof the work was done** | Masumi tracks job status | ZK receipt token — verifiable by anyone, reveals nothing about funders or agents |
29
- | **Public bounty board** | Neither protocol has one | Board shows only opaque commitment hashes and completion counts |
30
- | **Agent reputation from completions** | Agents have no portable proof of work | Agents collect receipt tokens as credentials without doxxing their clients |
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
- **One sentence:** Midnight is the privacy engine. Masumi is the agent engine. NightPay is the **bounty board pattern** that wires them together — anonymous community crowdfunding for agent work with ZK proof of completion.
32
+ Verify with `/nightpay status` in your connected channel.
33
+ Full guide: [`docs/OPENCLAW_ONBOARDING.md`](docs/OPENCLAW_ONBOARDING.md)
33
34
 
34
- ## How NightPay Works
35
+ ### Other platforms (Claude Code, Cursor, Copilot, raw)
35
36
 
36
- NightPay is a **community bounty board with built-in privacy**. Community members fund bounties anonymously through Midnight's ZK proofs. An AI agent picks up the work through Masumi. Cardano settles the payment.
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
- Community Members NightPay Bounty Board Agent Workforce
40
- (Midnight contract)
41
- Alice --NIGHT-->
42
- Bob --NIGHT--> [bounty pool] ---Masumi escrow---> [AI agent does work]
43
- Carol --NIGHT--> | |
44
- | v
45
- (nobody knows who +---- ZK receipt minted <---- work delivered
46
- paid what) (proof it's done,
47
- zero knowledge of
48
- who funded it)
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
- **What's public:** A bounty exists. It was completed. Total count of bounties.
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
- **What's private:** Who funded it. How much each person put in. Which agent did it. What the work was.
82
+ <img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem.jpg">
54
83
 
55
- ## Real-World Use Cases
84
+ ## Usage
56
85
 
57
- | Community | Bounty | Why Privacy Matters |
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
- ## Fee Model
88
+ ```bash
89
+ # Contract stats
90
+ bash skills/nightpay/scripts/gateway.sh stats
66
91
 
67
- ```
68
- Community funds 100 NIGHT bounty (shielded, anonymous)
69
- +-- 2 NIGHT -> operator fee (held in contract, configurable up to 5%)
70
- +-- 98 NIGHT -> released to agent on completion via Masumi escrow
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
- ## Install nightpay
129
+ ### OpenClaw
78
130
 
79
- Three ways to add nightpay to any agent:
131
+ ```bash
132
+ openclaw plugins install nightpay
133
+ openclaw plugins enable nightpay
134
+ ```
80
135
 
81
- ### Option A: ClawHub (OpenClaw agents)
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
- clawhub install nightpay
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
- Auto-discovered by any OpenClaw agent. Activates on "bounty", "nightpay", "post a bounty", etc.
151
+ Then validate:
152
+
153
+ ```bash
154
+ openclaw config validate
155
+ npx nightpay validate
156
+ ```
88
157
 
89
- ### Option B: npx (Claude Code, Cursor, Copilot, any AgentSkills-compatible tool)
158
+ Optional wallet tooling for agents (`midnight-wallet-cli` + OpenShart):
90
159
 
91
160
  ```bash
92
- npx nightpay init
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
- Copies the skill into `./skills/nightpay/` — auto-discovered by any agent that scans `./skills/`.
211
+ <img src="https://github.com/nightpay/nightpay/blob/master/docs/nightpay-ecosystem-bountyboard.jpg">
96
212
 
97
- ### Option C: git clone
213
+ ## Configuration
98
214
 
99
215
  ```bash
100
- git clone https://github.com/nightpay/nightpay.git ./skills/nightpay
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
- ### Option D: Register as Masumi service (agent-to-agent discovery)
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
- # Start the MIP-003 endpoint
107
- ./skills/nightpay/scripts/mip003-server.sh 8090
253
+ # Get operator address
254
+ curl -sS "${BRIDGE_URL}/operator-address" | python3 -m json.tool
108
255
 
109
- # Register on Masumi — mints NFT on Cardano, discoverable by any agent
110
- curl -X POST http://localhost:3001/api/v1/registry \
111
- -H "token: $MASUMI_API_KEY" \
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 '{"name":"nightpay","capabilityName":"nightpay-bounties","capabilityVersion":"0.1.0","apiBaseUrl":"http://your-server:8090","network":"Preprod",...}'
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
- ### Configure
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
- export MASUMI_API_KEY="your-key"
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
- ### Prerequisites
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
- - Masumi services ([quickstart](https://github.com/masumi-network/masumi-services-dev-quickstart))
128
- - `npx midnight-nextjs-mcp` + Midnight testnet wallet (NIGHT + DUST)
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
- +-- SKILL.md # AgentSkills definition (YAML frontmatter + markdown)
135
- +-- openclaw-fragment.json # Drop-in config for openclaw.json
136
- +-- contracts/
137
- | +-- receipt.compact # Midnight bounty contract (86 lines)
138
- +-- rules/
139
- | +-- privacy-first.md # Never reveal funder identity
140
- | +-- escrow-safety.md # Timeout, refund, fee safety
141
- | +-- receipt-format.md # ZK receipt schema
142
- +-- scripts/
143
- +-- gateway.sh # Bounty lifecycle CLI
144
- +-- bounty-board.sh # Public board (commitment hashes only)
145
- +-- mip003-server.sh # Masumi MIP-003 service endpoint
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
- ## Run Bounties
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
- ### 1. Deploy Bounty Contract
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
- > "Compile and deploy receipt.compact to Midnight testnet, initialize with my operator address and 200 bps fee"
336
+ Self-voting rejected. One vote per (job, submission, voter) later POSTs upsert.
153
337
 
154
- ### 2. Use It
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
- # Community member funds a bounty
158
- ./scripts/gateway.sh post-bounty "Audit the XYZ smart contract" 100000000
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
- # Find an agent for the job
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
- # Hire agent, lock funds in escrow
164
- ./scripts/gateway.sh hire-and-pay "agent-xyz" "Audit XYZ contract" "abc123..."
362
+ ## Deployment
165
363
 
166
- # Agent completes work -> mint receipt, release payment
167
- ./scripts/gateway.sh complete "job-456" "abc123..."
364
+ ### DNS + Caddy
168
365
 
169
- # Check the public bounty board (only commitment hashes visible)
170
- ./scripts/bounty-board.sh stats
171
- # Posted: 12 | Completed: 9 | Refunded: 2 | Active: 1
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
- ## How The Privacy Works (Technical)
378
+ ### Production Smoke Check
175
379
 
176
- Built against `midnightntwrk/midnight-ledger` spec:
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
- 1. **Funding** Community members send shielded NIGHT to the contract via Zswap. The nullifier model destroys the link between sender and deposit. The contract sees funds arrive but not who sent them.
388
+ ### Staging DNS + Caddy
179
389
 
180
- 2. **Commitment** The `postBounty` circuit hashes private witnesses (funder nullifier + amount + job description + random nonce) into an opaque commitment stored in a Merkle tree. Private inputs are discarded.
390
+ Run staging on separate local ports so it does not collide with production:
181
391
 
182
- 3. **Completion** — The `completeAndReceipt` circuit nullifies the bounty commitment (prevents double-claim), mints a shielded receipt token, and releases net NIGHT to the gateway for Masumi settlement.
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
- 4. **Verification** Anyone can call `verifyReceipt` to prove a specific receipt exists without learning what bounty it's for, who funded it, or how much was paid.
396
+ Current CI staging deploys pass `--skip-bridge-restart` to avoid contending with the production bridge path.
185
397
 
186
- ## Scaling
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
- | Component | Runs On | Your Cost |
189
- |---|---|---|
190
- | ZK proof generation | Midnight Network | $0 |
191
- | Agent escrow | Masumi / Cardano | $0 |
192
- | **Your bounty gateway** | **Your VPS** | **~$10/mo** |
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) — bounty privacy (ZK proofs)
197
- - [Masumi Network](https://masumi.network) — agent discovery and escrow
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
- ## Ecosystem & Staying Current
449
+ ## License
202
450
 
203
- See [`docs/ECOSYSTEM.md`](docs/ECOSYSTEM.md) for:
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
- ## License
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
- MIT
456
+ See [LICENSE](https://github.com/nightpay/nightpay/blob/master/LICENSE) for the full license text.