skuldr 0.0.0-stage → 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Skuldr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
1
+ # skuldr
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Check Skuldr's sealed agent receipts yourself, from a terminal. No account, no keys.
4
+
5
+ ```bash
6
+ npx skuldr verify 2026-12-02
7
+ ```
8
+
9
+ ```
10
+ Skuldr receipts for 2026-12-02 (UTC) · contract 0x34985339a088270b70bf60da9d1c6ef25e17aa79 on Robinhood Chain
11
+ ✓ hash ✓ leaf ✓ proof on chain house (v3)
12
+ ✓ Merkle root rebuilt from 1 receipt: 0xdbdaec68…1813a34f
13
+ ✓ root on chain: 0xdbdaec68…1813a34f (tx 0xd1cf2ddf…ca9eea09)
14
+
15
+ Everything matches.
16
+ ```
17
+
18
+ [Skuldr](https://skuldr.online) runs no-code options agents on paper (virtual money) over ETH on Robinhood Chain. Every decision an agent makes is logged, each UTC day's log is hashed, and all of a day's receipts go into one Merkle root. That root is written once to the [SkuldrReceipts](https://repo.sourcify.dev/contracts/full_match/4663/0x34985339a088270b70bf60da9d1c6ef25e17aa79/) contract, and the contract cannot change it later.
19
+
20
+ ## What it checks
21
+
22
+ For every receipt of the day:
23
+
24
+ 1. **hash**: SHA-256 of the day's canonical decision log, recomputed here from the log the server serves.
25
+ 2. **leaf**: `keccak256("skuldr-receipt|" + scope + "|" + version + "|" + day + "|" + hash)`.
26
+ 3. **root**: all leaves, sorted and hashed in pairs, rebuild the day's Merkle root.
27
+ 4. **on chain**: the root stored in the contract for that day is that root.
28
+ 5. **proof on chain**: the contract's own `verify(day, leaf, proof)` accepts each receipt.
29
+
30
+ The exit code is 0 when everything matches, and 1 otherwise. The reason is printed.
31
+
32
+ ## Options
33
+
34
+ ```
35
+ npx skuldr verify [YYYY-MM-DD] default: yesterday (UTC)
36
+ --api <url> Skuldr server (default https://skuldr.online)
37
+ --rpc <url> Robinhood Chain RPC (default https://robinhood.drpc.org)
38
+ --json machine-readable result
39
+ ```
40
+
41
+ Roots go on chain after 00:00 UTC for each finished day, starting with 2026-12-02. Earlier days have off-chain roots only.
42
+
43
+ ## As a library
44
+
45
+ ```js
46
+ import { verifyDay, leafOf, merkleRoot, verifyProof } from "skuldr";
47
+ const result = await verifyDay({ day: "2026-12-02" });
48
+ ```
49
+
50
+ ## Notes
51
+
52
+ Paper trading only. Not financial advice. MIT licensed. Source: [github.com/skuldrapp/skuldr](https://github.com/skuldrapp/skuldr).
package/bin/skuldr.mjs ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env node
2
+ // skuldr: check Skuldr's receipts and daily seals yourself, against the contract on Robinhood Chain.
3
+ // npx skuldr verify [YYYY-MM-DD] [--api https://skuldr.online] [--rpc https://robinhood.drpc.org] [--json]
4
+ // npx skuldr --help
5
+ import { verifyDay } from "../src/verify.mjs";
6
+
7
+ const args = process.argv.slice(2);
8
+ const flag = (name, fallback) => {
9
+ const i = args.indexOf(name);
10
+ return i >= 0 && args[i + 1] ? args[i + 1] : fallback;
11
+ };
12
+ const help = `skuldr — verify Skuldr's sealed receipts yourself
13
+
14
+ Usage:
15
+ npx skuldr verify [YYYY-MM-DD] check one UTC day (default: yesterday)
16
+
17
+ Options:
18
+ --api <url> Skuldr server to read receipts from (default https://skuldr.online)
19
+ --rpc <url> Robinhood Chain RPC to read the contract from (default https://robinhood.drpc.org)
20
+ --json print the result as JSON
21
+
22
+ What it checks, for every receipt of the day:
23
+ 1. its hash is SHA-256 of the day's canonical decision log, recomputed here
24
+ 2. its leaf is keccak256("skuldr-receipt|scope|version|day|hash")
25
+ 3. all leaves rebuild the day's Merkle root
26
+ 4. the root stored on chain in the SkuldrReceipts contract is that root
27
+ 5. the contract itself accepts each leaf's proof (verify())
28
+ Exit code 0 when everything matches, 1 when anything does not.
29
+
30
+ Paper trading only. Not financial advice.`;
31
+
32
+ const cmd = args.find((a) => !a.startsWith("--") && !/^https?:/.test(a));
33
+ if (!cmd || args.includes("--help") || args.includes("-h")) {
34
+ console.log(help);
35
+ process.exit(cmd || args.length ? 0 : 1);
36
+ }
37
+ if (cmd !== "verify") {
38
+ console.error(`Unknown command "${cmd}". Try: npx skuldr verify`);
39
+ process.exit(1);
40
+ }
41
+
42
+ const dayArg = args.find((a) => /^\d{4}-\d{2}-\d{2}$/.test(a));
43
+ const day = dayArg ?? new Date(Date.now() - 86_400_000).toISOString().slice(0, 10);
44
+ const api = flag("--api", "https://skuldr.online").replace(/\/$/, "");
45
+ const rpc = flag("--rpc", "https://robinhood.drpc.org");
46
+
47
+ try {
48
+ const r = await verifyDay({ day, api, rpc });
49
+ if (args.includes("--json")) console.log(JSON.stringify(r, null, 2));
50
+ else {
51
+ const mark = (ok) => (ok === true ? "✓" : ok === false ? "✗" : "·");
52
+ console.log(`Skuldr receipts for ${r.day} (UTC) · contract ${r.contract} on Robinhood Chain`);
53
+ for (const x of r.receipts) {
54
+ console.log(` ${mark(x.hashOk)} hash ${mark(x.leafOk)} leaf ${mark(x.proofOnChain)} proof on chain ${x.scope} (${x.version})${x.note ? ` · ${x.note}` : ""}`);
55
+ }
56
+ console.log(` ${mark(r.rootOk)} Merkle root rebuilt from ${r.receipts.length} receipt${r.receipts.length === 1 ? "" : "s"}: ${r.root}`);
57
+ console.log(` ${mark(r.onChainOk)} root on chain: ${r.onChainRoot ?? "not sealed yet"}${r.tx ? ` (tx ${r.tx})` : ""}`);
58
+ console.log(r.ok ? "\nEverything matches." : `\nNot verified: ${r.problems.join("; ")}`);
59
+ }
60
+ process.exit(r.ok ? 0 : 1);
61
+ } catch (e) {
62
+ console.error(`skuldr: ${e.message}`);
63
+ process.exit(1);
64
+ }
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "skuldr",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Verify Skuldr's sealed agent receipts yourself: recompute hashes and the daily Merkle root, and check them against the SkuldrReceipts contract on Robinhood Chain.",
5
+ "type": "module",
6
+ "bin": {
7
+ "skuldr": "bin/skuldr.mjs"
8
+ },
9
+ "exports": {
10
+ ".": "./src/verify.mjs"
11
+ },
12
+ "files": [
13
+ "bin",
14
+ "src",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "engines": {
19
+ "node": ">=18"
20
+ },
21
+ "dependencies": {
22
+ "@noble/hashes": "^1.8.0"
23
+ },
24
+ "keywords": [
25
+ "skuldr",
26
+ "paper-trading",
27
+ "options",
28
+ "merkle",
29
+ "receipts",
30
+ "robinhood-chain",
31
+ "verify"
32
+ ],
33
+ "homepage": "https://skuldr.online",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/skuldrapp/skuldr.git",
37
+ "directory": "verify"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/skuldrapp/skuldr/issues"
41
+ },
42
+ "license": "MIT",
43
+ "author": "Skuldr",
44
+ "scripts": {
45
+ "test": "node --test test/*.test.mjs"
46
+ }
47
+ }
package/src/verify.mjs ADDED
@@ -0,0 +1,98 @@
1
+ // The checks behind `npx skuldr verify`. Everything is recomputed here from public data:
2
+ // the server's receipts and the contract's storage. Nothing is trusted that can be recomputed.
3
+ import { keccak_256 } from "@noble/hashes/sha3";
4
+ import { sha256 } from "@noble/hashes/sha2";
5
+ import { bytesToHex, hexToBytes, utf8ToBytes } from "@noble/hashes/utils";
6
+
7
+ const hex = (b) => `0x${bytesToHex(b)}`;
8
+ const strip = (h) => h.replace(/^0x/, "").toLowerCase();
9
+
10
+ /** keccak256 of a UTF-8 string, as the contract and the server compute receipt leaves */
11
+ export const leafOf = (scope, version, day, hash) => hex(keccak_256(utf8ToBytes(`skuldr-receipt|${scope}|${version}|${day}|${hash}`)));
12
+
13
+ /** Hash a pair in sorted order, like SkuldrReceipts.verify() */
14
+ const pair = (a, b) => (strip(a) < strip(b) ? hex(keccak_256(hexToBytes(strip(a) + strip(b)))) : hex(keccak_256(hexToBytes(strip(b) + strip(a)))));
15
+
16
+ /** The Merkle root over leaves sorted first, pairing neighbours and carrying an odd one up */
17
+ export function merkleRoot(input) {
18
+ let layer = [...input].sort((x, y) => (strip(x) < strip(y) ? -1 : 1));
19
+ if (!layer.length) return `0x${"0".repeat(64)}`;
20
+ while (layer.length > 1) {
21
+ const next = [];
22
+ for (let i = 0; i < layer.length; i += 2) next.push(layer[i + 1] ? pair(layer[i], layer[i + 1]) : layer[i]);
23
+ layer = next;
24
+ }
25
+ return layer[0];
26
+ }
27
+
28
+ export const verifyProof = (leaf, proof, root) => strip(proof.reduce((h, p) => pair(h, p), leaf)) === strip(root);
29
+
30
+ const selector = (sig) => bytesToHex(keccak_256(utf8ToBytes(sig))).slice(0, 8);
31
+ const word = (n) => BigInt(n).toString(16).padStart(64, "0");
32
+
33
+ async function getJson(url) {
34
+ const res = await fetch(url, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(30_000) });
35
+ const body = await res.json().catch(() => ({}));
36
+ if (!res.ok) throw new Error(`${url}: ${body.error ?? `status ${res.status}`}`);
37
+ return body;
38
+ }
39
+
40
+ async function ethCall(rpc, to, data) {
41
+ const res = await fetch(rpc, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_call", params: [{ to, data }, "latest"] }), signal: AbortSignal.timeout(30_000) });
42
+ const j = await res.json();
43
+ if (j.error) throw new Error(`RPC: ${j.error.message}`);
44
+ return j.result;
45
+ }
46
+
47
+ /** The canonical decision log the receipt hash covers: the house agents' day, or one user agent's day */
48
+ async function canonicalFor(api, scope, day) {
49
+ const j = scope === "house" ? await getJson(`${api}/api/log/${day}`) : await getJson(`${api}/api/receipts/${scope}/${day}`);
50
+ return { canonical: j.canonical, version: j.version };
51
+ }
52
+
53
+ export async function verifyDay({ day, api = "https://skuldr.online", rpc = "https://robinhood.drpc.org" }) {
54
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(day)) throw new Error("Give the day as YYYY-MM-DD.");
55
+ const seal = await getJson(`${api}/api/seal/${day}`);
56
+ const problems = [];
57
+ const receipts = [];
58
+ for (const r of seal.receipts) {
59
+ const out = { scope: r.scope, version: r.version, hash: r.hash, leafOk: false, hashOk: null, proofOnChain: null, note: "" };
60
+ out.leafOk = strip(leafOf(r.scope, r.version, day, r.hash)) === strip(r.leaf);
61
+ if (!out.leafOk) problems.push(`${r.scope}: leaf does not match its hash`);
62
+ try {
63
+ const c = await canonicalFor(api, r.scope, day);
64
+ if (r.scope === "house" && c.version !== r.version) out.note = `log is served for settings ${c.version}; this receipt is ${r.version}`;
65
+ else {
66
+ out.hashOk = bytesToHex(sha256(utf8ToBytes(c.canonical))) === strip(r.hash);
67
+ if (!out.hashOk) problems.push(`${r.scope}: the decision log no longer hashes to the sealed hash`);
68
+ }
69
+ } catch (e) {
70
+ out.note = `log not readable: ${e.message}`;
71
+ }
72
+ receipts.push({ ...out, leaf: r.leaf, proof: r.proof });
73
+ }
74
+ const root = merkleRoot(seal.receipts.map((r) => r.leaf));
75
+ const rootOk = strip(root) === strip(seal.root);
76
+ if (!rootOk) problems.push("the receipts do not rebuild the published root");
77
+
78
+ let onChainRoot = null;
79
+ let onChainOk = false;
80
+ if (seal.contract) {
81
+ const stored = await ethCall(rpc, seal.contract, `0x${selector("roots(uint32)")}${word(seal.dayNumber)}`);
82
+ onChainRoot = /^0x0*$/.test(stored) ? null : `0x${strip(stored).slice(-64)}`;
83
+ onChainOk = !!onChainRoot && strip(onChainRoot) === strip(root);
84
+ if (!onChainRoot) problems.push("this day's root is not on chain yet (roots are written after 00:00 UTC, from 2026-12-02 on)");
85
+ else if (!onChainOk) problems.push("the root on chain differs from the rebuilt root");
86
+ if (onChainRoot) {
87
+ for (const r of receipts) {
88
+ // verify(uint32 day, bytes32 leaf, bytes32[] proof)
89
+ const data = `0x${selector("verify(uint32,bytes32,bytes32[])")}${word(seal.dayNumber)}${strip(r.leaf).padStart(64, "0")}${word(96)}${word(r.proof.length)}${r.proof.map((p) => strip(p).padStart(64, "0")).join("")}`;
90
+ r.proofOnChain = BigInt(await ethCall(rpc, seal.contract, data)) === 1n;
91
+ if (!r.proofOnChain) problems.push(`${r.scope}: the contract rejects this receipt's proof`);
92
+ }
93
+ }
94
+ } else problems.push("the server names no seal contract");
95
+
96
+ const ok = problems.length === 0 && receipts.every((r) => r.leafOk && r.hashOk !== false);
97
+ return { day, ok, root, rootOk, onChainRoot, onChainOk, contract: seal.contract, tx: seal.tx, receipts: receipts.map(({ proof, ...x }) => x), problems };
98
+ }