@moonbeam-foundation/sdk 0.5.2 → 0.7.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.
Files changed (106) hide show
  1. package/README.md +137 -38
  2. package/dist/abi/index.d.ts +55 -0
  3. package/dist/abi/index.d.ts.map +1 -0
  4. package/dist/abi/index.js +227 -0
  5. package/dist/abi/index.js.map +1 -0
  6. package/dist/acp/events.d.ts +38 -38
  7. package/dist/acp/events.d.ts.map +1 -1
  8. package/dist/acp/events.js.map +1 -1
  9. package/dist/acp/moonbeam-acp.generated.d.ts +50 -0
  10. package/dist/acp/moonbeam-acp.generated.d.ts.map +1 -0
  11. package/dist/acp/moonbeam-acp.generated.js +56 -0
  12. package/dist/acp/moonbeam-acp.generated.js.map +1 -0
  13. package/dist/acp/pipeline.js.map +1 -1
  14. package/dist/acp/registry.d.ts.map +1 -1
  15. package/dist/acp/registry.js +5 -3
  16. package/dist/acp/registry.js.map +1 -1
  17. package/dist/actors/track-record.js.map +1 -1
  18. package/dist/adapters/acp.js.map +1 -1
  19. package/dist/adapters/stamp.d.ts +1 -1
  20. package/dist/adapters/stamp.d.ts.map +1 -1
  21. package/dist/arbitration/index.d.ts +120 -0
  22. package/dist/arbitration/index.d.ts.map +1 -0
  23. package/dist/arbitration/index.js +116 -0
  24. package/dist/arbitration/index.js.map +1 -0
  25. package/dist/assurance/assurance-shared.d.ts +1924 -0
  26. package/dist/assurance/assurance-shared.d.ts.map +1 -0
  27. package/dist/assurance/assurance-shared.js +2225 -0
  28. package/dist/assurance/assurance-shared.js.map +1 -0
  29. package/dist/assurance/index.d.ts +57 -0
  30. package/dist/assurance/index.d.ts.map +1 -0
  31. package/dist/assurance/index.js +49 -0
  32. package/dist/assurance/index.js.map +1 -0
  33. package/dist/attest/index.d.ts +19 -0
  34. package/dist/attest/index.d.ts.map +1 -0
  35. package/dist/attest/index.js +17 -0
  36. package/dist/attest/index.js.map +1 -0
  37. package/dist/client/index.d.ts +16 -6
  38. package/dist/client/index.d.ts.map +1 -1
  39. package/dist/client/index.js +21 -1
  40. package/dist/client/index.js.map +1 -1
  41. package/dist/connect/logs.js.map +1 -1
  42. package/dist/core/money.js.map +1 -1
  43. package/dist/core/settle.js.map +1 -1
  44. package/dist/core/types.d.ts +1 -1
  45. package/dist/erc8004/index.d.ts +9 -9
  46. package/dist/erc8004/index.d.ts.map +1 -1
  47. package/dist/erc8004/index.js.map +1 -1
  48. package/dist/erc8183/index.d.ts +12 -12
  49. package/dist/erc8183/index.d.ts.map +1 -1
  50. package/dist/erc8183/index.js.map +1 -1
  51. package/dist/index.d.ts +7 -0
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +8 -0
  54. package/dist/index.js.map +1 -1
  55. package/dist/judge/index.d.ts +35 -3
  56. package/dist/judge/index.d.ts.map +1 -1
  57. package/dist/judge/index.js +41 -2
  58. package/dist/judge/index.js.map +1 -1
  59. package/dist/launcher/index.d.ts +3 -3
  60. package/dist/launcher/index.d.ts.map +1 -1
  61. package/dist/onboard/index.d.ts +64 -24
  62. package/dist/onboard/index.d.ts.map +1 -1
  63. package/dist/onboard/index.js +90 -15
  64. package/dist/onboard/index.js.map +1 -1
  65. package/dist/pools/index.d.ts +49 -7
  66. package/dist/pools/index.d.ts.map +1 -1
  67. package/dist/pools/index.js +30 -6
  68. package/dist/pools/index.js.map +1 -1
  69. package/dist/proof/index.d.ts +117 -0
  70. package/dist/proof/index.d.ts.map +1 -0
  71. package/dist/proof/index.js +81 -0
  72. package/dist/proof/index.js.map +1 -0
  73. package/dist/resale/index.d.ts +120 -0
  74. package/dist/resale/index.d.ts.map +1 -0
  75. package/dist/resale/index.js +117 -0
  76. package/dist/resale/index.js.map +1 -0
  77. package/dist/resale/payment-scheme.d.mts +46 -0
  78. package/dist/resale/payment-scheme.mjs +351 -0
  79. package/dist/resale/payment-scheme.pin.json +6 -0
  80. package/dist/rpc/index.d.ts +24 -0
  81. package/dist/rpc/index.d.ts.map +1 -0
  82. package/dist/rpc/index.js +66 -0
  83. package/dist/rpc/index.js.map +1 -0
  84. package/dist/x402/index.d.ts +90 -0
  85. package/dist/x402/index.d.ts.map +1 -0
  86. package/dist/x402/index.js +75 -0
  87. package/dist/x402/index.js.map +1 -0
  88. package/examples/03-end-to-end-offline.mjs +2 -2
  89. package/examples/14-grade-record.mjs +6 -4
  90. package/examples/17-grade-live.mjs +1 -1
  91. package/examples/20-onboard-client.mjs +2 -2
  92. package/examples/24-resell-on-base.mjs +17 -0
  93. package/examples/{30-read-a-real-job.mjs → 30-read-a-job.mjs} +2 -2
  94. package/examples/32-read-live-from-base.mjs +8 -11
  95. package/examples/40-the-article.mjs +1 -1
  96. package/examples/50-x402-pay-a-wall.mjs +17 -0
  97. package/examples/51-read-a-proof.mjs +21 -0
  98. package/examples/52-arbitration-calls.mjs +13 -0
  99. package/examples/53-attested-by-default.mjs +19 -0
  100. package/examples/README.md +13 -6
  101. package/examples/data/proof-base-tx-52587000.json +116 -0
  102. package/package.json +51 -10
  103. package/skills/moonbeam-actor-backer/SKILL.md +1 -1
  104. package/skills/moonbeam-actor-challenger/SKILL.md +1 -1
  105. package/skills/moonbeam-actor-doubter/SKILL.md +1 -1
  106. package/skills/moonbeam-assurance/SKILL.md +1 -1
@@ -0,0 +1,75 @@
1
+ import { REGISTRY } from '../acp/moonbeam-acp.generated.js';
2
+ import { subscribePlan } from '../resale/index.js';
3
+ export const X402_BASE_NETWORK = 'eip155:8453';
4
+ const ADDR = /^0x[0-9a-fA-F]{40}$/;
5
+ /** the x402 body inside a wall's 402 answer (`{ x402: {…} }` or the bare body) */
6
+ export function x402Of(answer) {
7
+ const o = answer;
8
+ const b = (o && 'x402' in o && o.x402 ? o.x402 : o);
9
+ if (!b || !Array.isArray(b.accepts))
10
+ throw new Error('not an x402 answer: no accepts[]');
11
+ return b;
12
+ }
13
+ /** the `exact` USDC entry on Base; anything else is refused (Base only) */
14
+ export function baseAccept(answer) {
15
+ const b = x402Of(answer);
16
+ const a = b.accepts.find((x) => x.scheme === 'exact' && (x.network === X402_BASE_NETWORK || x.network === 'base'));
17
+ if (!a)
18
+ throw new Error(`the wall offers no exact payment on Base (networks: ${b.accepts.map((x) => x.network).join(', ') || 'none'})`);
19
+ if (a.asset.toLowerCase() !== REGISTRY.usdc.toLowerCase())
20
+ throw new Error(`the Base entry asks for ${a.asset}, not USDC on Base`);
21
+ if (!ADDR.test(a.payTo))
22
+ throw new Error(`payTo ${a.payTo} is not an address`);
23
+ return a;
24
+ }
25
+ const amountOf = (a) => BigInt(a.amount ?? a.maxAmountRequired ?? (() => { throw new Error('the entry names no amount'); })());
26
+ const hex32 = (b) => `0x${Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('')}`;
27
+ /** a fresh 32-byte nonce (crypto.getRandomValues) */
28
+ export const randomNonce = () => hex32(globalThis.crypto.getRandomValues(new Uint8Array(32)));
29
+ /** The EIP-3009 typed data for one Base entry. validAfter defaults to 0, validBefore to now + maxTimeoutSeconds. */
30
+ export function transferAuthorization(a, o) {
31
+ if (!ADDR.test(o.from))
32
+ throw new Error(`from ${o.from} is not an address`);
33
+ if (a.network !== X402_BASE_NETWORK && a.network !== 'base')
34
+ throw new Error('Base only: this entry is on ' + a.network);
35
+ const now = o.now ?? Math.floor(Date.now() / 1000);
36
+ const nonce = o.nonce ?? randomNonce();
37
+ if (!/^0x[0-9a-fA-F]{64}$/.test(nonce))
38
+ throw new Error('the nonce is 32 bytes');
39
+ return {
40
+ domain: { name: a.extra?.name ?? 'USD Coin', version: a.extra?.version ?? '2', chainId: 8453, verifyingContract: a.asset },
41
+ types: { TransferWithAuthorization: [
42
+ { name: 'from', type: 'address' }, { name: 'to', type: 'address' }, { name: 'value', type: 'uint256' },
43
+ { name: 'validAfter', type: 'uint256' }, { name: 'validBefore', type: 'uint256' }, { name: 'nonce', type: 'bytes32' },
44
+ ] },
45
+ primaryType: 'TransferWithAuthorization',
46
+ message: { from: o.from, to: a.payTo, value: amountOf(a).toString(), validAfter: String(o.validAfter ?? 0), validBefore: String(o.validBefore ?? now + a.maxTimeoutSeconds), nonce },
47
+ };
48
+ }
49
+ /** The X-PAYMENT header value: base64 of { x402Version, scheme, network, payload: { signature, authorization } } */
50
+ export function paymentHeader(a, authorization, signature, x402Version = 2) {
51
+ if (!/^0x[0-9a-fA-F]{130}$/.test(signature))
52
+ throw new Error('the signature is 65 bytes (0x + 130 hex)');
53
+ const json = JSON.stringify({ x402Version, scheme: a.scheme, network: a.network, payload: { signature, authorization } });
54
+ return typeof Buffer !== 'undefined' ? Buffer.from(json, 'utf8').toString('base64') : btoa(json);
55
+ }
56
+ /** GET a wall and return its 402 quote (Base entry + the whole body). Nothing is paid. */
57
+ export async function quoteWall(t, path) {
58
+ const r = await t.fetch(`${t.base}${path.startsWith('/') ? path : `/${path}`}`, { method: 'GET', headers: { accept: 'application/json', ...(t.apiKey ? { 'x-api-key': t.apiKey } : {}) } });
59
+ const j = await r.json().catch(() => null);
60
+ if (r.status !== 402)
61
+ throw new Error(`expected a 402 quote, got ${r.status}`);
62
+ const body = x402Of(j);
63
+ return { status: r.status, accept: baseAccept(body), body };
64
+ }
65
+ /** POST /v1/access/subscribe with a subscribePlan(): the layer answers with the top-up's x402 quote (a 402) */
66
+ export async function subscribe(t, plan = subscribePlan()) {
67
+ const r = await t.fetch(`${t.base}${plan.path}`, { method: plan.method, headers: { 'content-type': 'application/json', accept: 'application/json', ...(t.apiKey ? { 'x-api-key': t.apiKey } : {}) }, body: JSON.stringify(plan.body) });
68
+ const body = await r.json().catch(() => null);
69
+ let accept = null;
70
+ if (r.status === 402)
71
+ accept = baseAccept(body);
72
+ return { status: r.status, accept, body };
73
+ }
74
+ export { subscribePlan };
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/x402/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,aAA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
1
- // The whole covered job, offline, from a real Base trail: read the job's logs, grade the delivery, settle the money.
1
+ // The whole covered job, offline, from a Base trail: read the job's logs, grade the delivery, settle the money.
2
2
  // No key, no network. Every step asserts its own result, so this file doubles as a check.
3
3
  // node examples/03-end-to-end-offline.mjs
4
4
  import { readFileSync } from 'node:fs';
@@ -8,7 +8,7 @@ import { gradeJob, verifyGrade } from '@moonbeam-foundation/sdk/judge';
8
8
  import { TERMS } from './data/terms.mjs';
9
9
  import { CLEAN } from './data/answers.mjs';
10
10
 
11
- // 1. read: the real trail of Virtuals ACP job 74926 on Base
11
+ // 1. read: the trail of Virtuals ACP job 74926 on Base
12
12
  const logs = JSON.parse(readFileSync(new URL('./data/virtuals-job-74926.json', import.meta.url), 'utf8'));
13
13
  const prepared = prepareSettlement(logs, TERMS, localClock(Math.floor(Date.UTC(2026, 8, 1) / 1000)));
14
14
  assert.equal(prepared.ready, true);
@@ -1,11 +1,13 @@
1
- // Grader stage 5: the record (optional). The unsigned calls that put the answers and the decision on chain.
2
- // Recording is your choice: nothing here signs or sends; hand the calls to your own wallet.
1
+ // Grader stage 5: the record. Every grade comes with the unsigned calls that put its answers and its decision on chain,
2
+ // on Base by default; a stamp registry Base does not have is listed as missing. network 'none' turns recording off.
3
+ // Nothing here signs or sends; hand the calls to your own wallet.
3
4
  // node examples/14-grade-record.mjs
4
5
  import { gradeJob, recordGrade } from '@moonbeam-foundation/sdk/judge';
5
6
  import { CLEAN, PILOT_JOB } from './data/answers.mjs';
6
7
 
7
8
  const receipt = await gradeJob({ jobId: PILOT_JOB, evidence: 'the report', answers: CLEAN, model: 'jev-1.13.0' });
9
+ const base = await recordGrade(receipt);
10
+ for (const c of base.calls) console.log(`${c.fn} on chain ${c.chainId} → ${c.to} · ${c.data.length / 2 - 1} bytes of calldata`);
11
+ for (const m of base.missing) console.log(`missing: ${m.why}`);
8
12
  const none = await recordGrade(receipt, { network: 'none' });
9
13
  console.log('network none →', none.calls.length, 'calls; digests only:', none.digests.decision);
10
- const base = await recordGrade(receipt, { network: 'base' });
11
- for (const c of base.calls) console.log(`${c.fn} on chain ${c.chainId} → ${c.to} · ${c.data.length / 2 - 1} bytes of calldata`);
@@ -1,4 +1,4 @@
1
- // Grade a job with Jev for real, on your own TypeSafe key (console.typesafe.ai). Without a key it explains and stops.
1
+ // Grade a job with Jev live, on your own TypeSafe key (console.typesafe.ai). Without a key it explains and stops.
2
2
  // TYPESAFE_KEY=… node examples/17-grade-live.mjs
3
3
  import { gradeJob, jobFacts, endJob } from '@moonbeam-foundation/sdk/judge';
4
4
  import { PILOT_JOB } from './data/answers.mjs';
@@ -1,8 +1,8 @@
1
- // Onboarding, buyer: before you fund a covered job, see what the cover really pays and what it leaves uncovered.
1
+ // Onboarding, buyer: before you fund a covered job, see what the cover pays and what it leaves uncovered.
2
2
  // node examples/20-onboard-client.mjs
3
3
  import { readinessForClient, blockers, summarise } from '@moonbeam-foundation/sdk';
4
4
  import { TERMS, usdc, show } from './data/terms.mjs';
5
5
 
6
- const r = readinessForClient({ terms: TERMS, trueLoss: usdc('500') }); // what a failure would really cost you
6
+ const r = readinessForClient({ terms: TERMS, trueLoss: usdc('500') }); // what a failure would cost you
7
7
  show(r, summarise);
8
8
  console.log('blockers:', blockers(r).length);
@@ -0,0 +1,17 @@
1
+ // Reselling on Base: what a Moonbeam reseller's visitor pays for a job, where every unit of it goes, and the reseller's own leg.
2
+ // The numbers are the coordination layer's ONE payment scheme (a pinned copy); the venues are the five Base venues. Offline; no key.
3
+ // node examples/24-resell-on-base.mjs
4
+ import { quoteBase, legsByName, markupLeg, childKeyTerms, BASE_VENUES } from '@moonbeam-foundation/sdk/resale';
5
+
6
+ const sellerPrice = 8_000n; // the doer's own price: 0.008 USDC
7
+ const rows = [];
8
+ for (const venue_out of BASE_VENUES) {
9
+ const q = quoteBase({ venue_in: 'reseller', venue_out, seller_price: sellerPrice, reseller: { tenant: 'acct_moonbeam', markup_bps: 1000 } });
10
+ if (!q.ok) { console.log(`${venue_out}: refused: ${q.why}`); continue; }
11
+ const l = legsByName(q);
12
+ rows.push({ venue_out, buyer_pays: q.price_to_buyer, our_fee: l.our_fee.toString(), venue_fee: l.venue_fee.toString(), seller: l.seller_share.toString(), markup: markupLeg(q).units.toString() });
13
+ }
14
+ console.table(rows);
15
+ const first = rows[0];
16
+ console.log(`the doer keeps ${first.seller} on every venue; the reseller's leg is ${first.markup} (10 % of the list price); Σ legs = the price on every row`);
17
+ console.log(childKeyTerms({ '*': 1000 }).says[1]);
@@ -1,6 +1,6 @@
1
- // Read a real job: decode real agent jobs from their Base logs (Virtuals ACP, captured from mainnet) and fold each into one
1
+ // Read a job: decode agent jobs from their Base logs (Virtuals ACP, captured from mainnet) and fold each into one
2
2
  // state: what happened, how it settles, and who judged it. Offline: the logs are in examples/data/.
3
- // node examples/30-read-a-real-job.mjs
3
+ // node examples/30-read-a-job.mjs
4
4
  import { readFileSync } from 'node:fs';
5
5
  import { decodeAcpLogs, foldTask, toOutcome, localClock } from '@moonbeam-foundation/sdk';
6
6
 
@@ -1,27 +1,24 @@
1
- // Read live: one real job's events straight from a public Base RPC, decode and fold them. Read only; no key.
1
+ // Read live: one job's events straight from Base, decode and fold them. Read only; no key.
2
+ // The reads go through the SDK's Base reader: warmbed's measured rotation of Base endpoints, so a rate-limited or
3
+ // range-capped endpoint moves the call to the next one.
2
4
  // node examples/32-read-live-from-base.mjs Virtuals ACP job 74926 (the one captured in data/)
3
5
  // JOB=12345 FROM_BLOCK=50000000 node examples/32-read-live-from-base.mjs
4
- // BASE_RPC=https://your-rpc node examples/32-read-live-from-base.mjs
6
+ // BASE_RPC=https://your-rpc node examples/32-read-live-from-base.mjs (your endpoint goes first)
5
7
  import { decodeAcpLogs, foldTask, toOutcome, localClock, VIRTUALS_ACP_ADDRESS, ACP_TOPIC0 } from '@moonbeam-foundation/sdk';
8
+ import { baseReader } from '@moonbeam-foundation/sdk/rpc';
6
9
 
7
- const RPC = process.env.BASE_RPC ?? 'https://mainnet.base.org';
10
+ const reader = baseReader();
8
11
  const job = BigInt(process.env.JOB ?? 74926);
9
12
  const from = Number(process.env.FROM_BLOCK ?? 50_427_200);
10
13
  const SPAN = 500, WINDOWS = Number(process.env.WINDOWS ?? 4); // public RPCs cap the block range per call
11
-
12
- async function rpc(method, params) {
13
- const res = await fetch(RPC, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method, params }) });
14
- const body = await res.json();
15
- if (body.error) throw new Error(`${method}: ${body.error.message}`);
16
- return body.result;
17
- }
14
+ const rpc = (method, params, need = 'call') => reader.call(method, params, need);
18
15
 
19
16
  const virtuals = ['jobCreated', 'budgetSet', 'jobFunded', 'paymentReleased', 'jobRefunded', 'jobSubmitted', 'jobCompleted', 'jobRejected', 'jobExpired', 'evaluatorFeePaid'].map((k) => ACP_TOPIC0[k]);
20
17
  const jobTopic = '0x' + job.toString(16).padStart(64, '0');
21
18
  const logs = [];
22
19
  for (let i = 0; i < WINDOWS; i++) {
23
20
  const lo = from + i * SPAN, hi = lo + SPAN - 1;
24
- logs.push(...(await rpc('eth_getLogs', [{ address: VIRTUALS_ACP_ADDRESS, topics: [virtuals, jobTopic], fromBlock: '0x' + lo.toString(16), toBlock: '0x' + hi.toString(16) }])));
21
+ logs.push(...(await rpc('eth_getLogs', [{ address: VIRTUALS_ACP_ADDRESS, topics: [virtuals, jobTopic], fromBlock: '0x' + lo.toString(16), toBlock: '0x' + hi.toString(16) }], 'logs')));
25
22
  }
26
23
  const events = decodeAcpLogs(logs);
27
24
  console.log(`job ${job}, blocks ${from}–${from + WINDOWS * SPAN - 1}: ${events.length} events`);
@@ -19,7 +19,7 @@ const data = (f) => JSON.parse(readFileSync(new URL(`./data/${f}`, import.meta.u
19
19
  title('"It reads the chain. It decodes ERC-8183 logs into one job state, says who can act next, and says which endings need a grader."');
20
20
  {
21
21
  const state = foldTask(decodeAcpLogs(data('virtuals-job-74926.json')));
22
- check('decodes a real Base job\'s logs into one state', state.work === 'graded' || state.escrow !== 'none', `job ${state.id}: ${state.work}`);
22
+ check('decodes a Base job\'s logs into one state', state.work === 'graded' || state.escrow !== 'none', `job ${state.id}: ${state.work}`);
23
23
  const clock = localClock(Math.floor(Date.UTC(2026, 8, 1) / 1000));
24
24
  const acts = availableActions(state, clock);
25
25
  check('says who can act next', Array.isArray(acts), `${acts.length} action(s) open · waiting on ${waitingOn(state, clock) ?? 'nobody (ended)'}`);
@@ -0,0 +1,17 @@
1
+ // x402 on Base: read a wall's 402 quote, pick its Base entry, and build the USDC payment your wallet signs (EIP-3009
2
+ // transferWithAuthorization) and the X-PAYMENT header that carries it. Nothing is signed or paid here.
3
+ // node examples/50-x402-pay-a-wall.mjs a paid answer of the class mcp.digest, quoted live
4
+ // OFFLINE=1 node examples/50-x402-pay-a-wall.mjs the same, from the recorded quote
5
+ // test/fork/run-fork.mjs signs it and executes it on a Base fork
6
+ import { quoteWall, baseAccept, transferAuthorization, subscribePlan } from '@moonbeam-foundation/sdk/x402';
7
+ import { quoteSale } from '@moonbeam-foundation/sdk/resale';
8
+
9
+ const t = { base: 'https://coord.taifoon.dev/v1', fetch: (u, i) => fetch(u, i) };
10
+ const recorded = { x402: { x402Version: 2, accepts: [{ scheme: 'exact', network: 'eip155:8453', amount: '11509', asset: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', payTo: '0x3574999dd4c96eB73Bd6e11D4177010C83E14f5b', maxTimeoutSeconds: 300, extra: { name: 'USD Coin', version: '2' } }] } };
11
+ const accept = process.env.OFFLINE ? baseAccept(recorded) : (await quoteWall(t, '/x402/class/mcp.digest')).accept;
12
+ console.log(`the wall asks ${accept.amount} USDC units on ${accept.network}, paid to ${accept.payTo}`);
13
+ const q = quoteSale({ venue_in: 'x402-base', venue_out: 'x402-base', seller_price: 9207n });
14
+ console.log(`quoteSale: the seller's 9207 → the buyer pays ${q.price_to_buyer} (the same scheme the wall prices with)`);
15
+ const typed = transferAuthorization(accept, { from: '0x000000000000000000000000000000000000dEaD' });
16
+ console.log(`your wallet signs ${typed.primaryType} under ${typed.domain.name} v${typed.domain.version} on chain ${typed.domain.chainId}: value ${typed.message.value}, valid before ${typed.message.validBefore}`);
17
+ console.log('then paymentHeader(accept, typed.message, signature) is the X-PAYMENT header; a top-up starts at', JSON.stringify(subscribePlan({ usdc: 1 }).body));
@@ -0,0 +1,21 @@
1
+ // A proof that a Base transaction is inside the layer's superroot, and the V5 proof verifier on Base checking it.
2
+ // node examples/51-read-a-proof.mjs [txHash] read the proof live, then verify(blob) by eth_call on Base
3
+ // OFFLINE=1 node examples/51-read-a-proof.mjs the recorded proof, and the call that Base answered true for
4
+ import { readFileSync } from 'node:fs';
5
+ import { readProof, verifyCall, verifyOnBase } from '@moonbeam-foundation/sdk/proof';
6
+ import { baseReader } from '@moonbeam-foundation/sdk/rpc';
7
+
8
+ const tx = process.argv[2] ?? '0x48f87043df02dc8f97c3a70afb8c8748848d0efae865cb251c429cce57bc127f';
9
+ if (process.env.OFFLINE) {
10
+ const p = JSON.parse(readFileSync(new URL('./data/proof-base-tx-52587000.json', import.meta.url), 'utf8'));
11
+ const c = verifyCall(p.blob);
12
+ console.log(`recorded proof of ${p.tx}: block ${p.block_number}, superroot 0x${p.super_root_hash}`);
13
+ console.log(`verify(blob) → ${c.to}, bound at block ${c.boundAt.blockNumber}, ${c.data.length / 2 - 1} bytes of calldata`);
14
+ process.exit(0);
15
+ }
16
+ const p = await readProof({ base: 'https://coord.taifoon.dev/v1', fetch: (u, i) => fetch(u, i) }, tx);
17
+ console.log(`proof of ${p.tx}: block ${p.block_number} · proven by the layer: ${p.proven} · ${p.ref}`);
18
+ if (p.blob) {
19
+ const c = await verifyOnBase(baseReader(), p.blob);
20
+ console.log(`verify(blob) on Base: ${c.verified}${c.error ? ` (${c.error})` : ''} · superroot anchored on chain: ${c.anchored} · block bound by: ${c.inclusion === 'served' ? 'the served inclusion path' : 'the header itself'}`);
21
+ }
@@ -0,0 +1,13 @@
1
+ // Arbitration: the three tiers of the ArbitratorRouter as unsigned calls, the verdict the second grader signs, and what
2
+ // a ruling writes into the seller's record. Offline.
3
+ // node examples/52-arbitration-calls.mjs
4
+ import { ARBITRATION_ON_BASE, resolveByCode, secondGraderTypedData, verdictDigest, councilApprove, resolveByCouncil, recordEffectOf } from '@moonbeam-foundation/sdk/arbitration';
5
+
6
+ console.log(ARBITRATION_ON_BASE.says);
7
+ const router = '0x00000000000000000000000000000000000000ab'; // pass the router's address once it is deployed
8
+ const jobId = '0x' + '11'.repeat(32);
9
+ console.log('tier 0, anyone:', resolveByCode(router, jobId).fn);
10
+ const v = { jobId, verdict: 'Cheated', loss: 10n ** 18n, decisionDigest: '0x' + '22'.repeat(32) };
11
+ console.log('tier 1, the second grader signs', secondGraderTypedData(router, v).primaryType, '→ digest', verdictDigest(router, v));
12
+ console.log('tier 2, the human seat:', councilApprove(router, jobId, 'Cheated', 10n ** 18n).fn, '· then anyone:', resolveByCouncil(router, jobId).fn);
13
+ console.log('a Cheated ruling:', recordEffectOf('Cheated').hook, '· seller record:', recordEffectOf('Cheated').sellerRecord);
@@ -0,0 +1,19 @@
1
+ // Every step comes attested: a settle, a grade and a resale step each return their mark (a digest anyone recomputes)
2
+ // and the unsigned calls that put it on Base. Base has the decision log and the answer log; a stamp registry it does not
3
+ // have is listed as missing, not faked. networks: 'none' turns recording off. Offline.
4
+ // node examples/53-attested-by-default.mjs
5
+ import { settleAttested, hookQuote, readJob } from '@moonbeam-foundation/sdk/assurance';
6
+ import { gradeJob, recordGrade } from '@moonbeam-foundation/sdk/judge';
7
+ import { attestSale, quoteSale } from '@moonbeam-foundation/sdk/resale';
8
+ import { CLEAN, PILOT_JOB } from './data/answers.mjs';
9
+
10
+ const trail = readJob([1, 2, 3].map((hookState) => ({ name: 'hook', hookState })));
11
+ const s = settleAttested({ venue: 'moonbeam', ctx: { lane: 'hook', hook: 'V3' }, chainId: 8453, jobId: PILOT_JOB, buyer: '0x' + '0'.repeat(39) + '1', seller: '0x' + '0'.repeat(39) + '2', evaluator: null, terms: null, clock: {}, state: trail.state, path: trail.path },
12
+ hookQuote({ price: 10n * 10n ** 18n, premium: 10n ** 17n, deposit: 12n * 10n ** 18n, covered: true }));
13
+ const show = (label, a) => console.log(`${label}: mark ${a.mark.digest.slice(0, 18)}… → ${a.calls.map((c) => `${c.fn}@${c.chainId}`).join(', ')}${a.missing.length ? ` · missing: ${a.missing.map((m) => `${m.contract}@${m.chainId}`).join(', ')}` : ''}`);
14
+ show(`settle (${s.ending.id}), Base 8453`, s.attest);
15
+ const g = await recordGrade(await gradeJob({ jobId: PILOT_JOB, evidence: 'the report', answers: CLEAN, model: 'jev-1.13.0' }));
16
+ console.log(`grade: ${g.calls.map((c) => `${c.fn}@${c.chainId}`).join(', ')} · missing: ${g.missing.map((m) => `${m.contract}@${m.chainId}`).join(', ')}`);
17
+ const q = quoteSale({ venue_in: 'x402-base', venue_out: 'erc8183-base', seller_price: 1_000_000n });
18
+ show('resale quoted', attestSale({ saleKey: 'rs_example_0123456789', step: 'quoted', quote: q }));
19
+ console.log('opted out:', attestSale({ saleKey: 'rs_example_0123456789', step: 'quoted', quote: q }, { networks: 'none' }).status);
@@ -1,7 +1,9 @@
1
1
  # Examples
2
2
 
3
- Every example is one file you run with `node`. All except two run offline, with no key and no wallet; the jobs they use are real
4
- Base jobs captured into [`data/`](data). `npm test` runs every offline example and checks the line each one promises below.
3
+ Every example is one file you run with `node`. All except four run offline, with no key and no wallet; the jobs they use are
4
+ Base jobs captured into [`data/`](data). 17 and 32 read live; 50 and 51 read live and run offline with `OFFLINE=1`. `npm test`
5
+ runs every offline example and checks the line each one promises below. `test/fork/run-fork.mjs` sends the write paths on a
6
+ local fork of Base.
5
7
 
6
8
  ```sh
7
9
  npm i @moonbeam-foundation/sdk
@@ -23,7 +25,7 @@ reading jobs that already ran ────────▶ 30, 31, 33, then 32 li
23
25
 
24
26
  | # | File | Best for | You see |
25
27
  |---|---|---|---|
26
- | 03 | [end-to-end-offline](03-end-to-end-offline.mjs) | **Start here.** One real job from its Base trail to who ends up with what | `3 settle client -101 · provider +100 · pool +1 · sums to zero` |
28
+ | 03 | [end-to-end-offline](03-end-to-end-offline.mjs) | **Start here.** One job from its Base trail to who ends up with what | `3 settle client -101 · provider +100 · pool +1 · sums to zero` |
27
29
  | 01 | [settle-a-covered-job](01-settle-a-covered-job.mjs) | The four ways a covered job can end, in money | four ledgers, each `sums to zero: true` |
28
30
  | 02 | [negotiate-a-hire](02-negotiate-a-hire.mjs) | A buyer posts, two agents bid, the thin bond is refused | `agent-b refused: DEPOSIT_BELOW_JOB` |
29
31
 
@@ -38,7 +40,7 @@ Stages 1–7 run offline on recorded answers; 17 runs the same thing live.
38
40
  | 11 | [facts](11-grade-facts.mjs) | Code checks what code can check. A failed check rejects without asking a model | `checksOk: false` |
39
41
  | 12 | [answers](12-grade-answers.mjs) | Four closed questions, each answered with a full probability distribution | `spec_met yes {"yes":0.95,"no":0.05}` |
40
42
  | 13 | [verdict](13-grade-verdict.mjs) | complete, reject or needs_review, from published thresholds | `UNSURE → needs_review mid band: …` |
41
- | 14 | [record](14-grade-record.mjs) | Optional: the unsigned calls that put the grade on Base. Off by default | `network none → 0 calls` |
43
+ | 14 | [record](14-grade-record.mjs) | The unsigned calls that put the grade on Base, built by default; `network: 'none'` turns them off | `network none → 0 calls` |
42
44
  | 15 | [end the job](15-grade-end-the-job.mjs) | The one unsigned call that completes or rejects the job on the hook | `complete → complete(bytes32) to 0xc057…` |
43
45
  | 16 | [verify](16-grade-verify.mjs) | Anyone can recompute a grade; a changed verdict is caught | `tampered: false` |
44
46
  | 17 | [live](17-grade-live.mjs) | The same grade, answered live on your own key | a receipt, or how to get a key |
@@ -53,14 +55,15 @@ Each role gets a readiness report: what you put up, what you can lose, and anyth
53
55
  | 21 | [onboard-provider](21-onboard-provider.mjs) | Doing the work | `[block] this job needs a 40 deposit and you have 30 free` |
54
56
  | 22 | [onboard-evaluator](22-onboard-evaluator.mjs) | Judging the work | `[caution] without a verifiable proof you can reject but never approve` |
55
57
  | 23 | [onboard-backer](23-onboard-backer.mjs) | Standing behind workers (pools are not open yet; this is the arithmetic) | `breaks even at 3.23%` |
58
+ | 24 | [resell-on-base](24-resell-on-base.mjs) | A Moonbeam reseller's quote on every Base venue: the one scheme, the doer keeps its price, the reseller's leg | `the doer keeps 8000 on every venue` |
56
59
 
57
60
  ## Reading jobs that already ran
58
61
 
59
62
  | # | File | What it shows | You see |
60
63
  |---|---|---|---|
61
- | 30 | [read-a-real-job](30-read-a-real-job.mjs) | Decode two real Virtuals ACP jobs from their Base logs | `settles as: rejected (evaluatorRejected)` |
64
+ | 30 | [read-a-job](30-read-a-job.mjs) | Decode two Virtuals ACP jobs from their Base logs | `settles as: rejected (evaluatorRejected)` |
62
65
  | 31 | [read-the-ending](31-read-the-ending.mjs) | Which endings the trail decides alone, and which need a grader | `cannot_determine (needs a grader)` |
63
- | 32 | [read-live-from-base](32-read-live-from-base.mjs) | The same, straight from a public Base RPC | `6 events` for job 74926 |
66
+ | 32 | [read-live-from-base](32-read-live-from-base.mjs) | The same, straight from Base through the SDK's Base reader | `6 events` for job 74926 |
64
67
  | 33 | [read-many-jobs](33-read-many-jobs.mjs) | Many jobs at once: how many were judged by someone other than the buyer | `2 jobs · self-judged: 2` |
65
68
 
66
69
  ## The article, claim by claim
@@ -68,6 +71,10 @@ Each role gets a readiness report: what you put up, what you can lose, and anyth
68
71
  | # | File | What it shows | You see |
69
72
  |---|---|---|---|
70
73
  | 40 | [the-article](40-the-article.mjs) | Every claim the launch article makes about the SDK, checked. Live, it also finds the equation job's grade on Base (`OFFLINE=1` skips that) | `every claim holds` |
74
+ | 50 | [x402-pay-a-wall](50-x402-pay-a-wall.mjs) | A wall's 402 on Base, `quoteSale`'s price for it, and the EIP-3009 typed data your wallet signs | `signs TransferWithAuthorization under USD Coin v2 on chain 8453` |
75
+ | 51 | [read-a-proof](51-read-a-proof.mjs) | A Base transaction's proof from the layer, then `verify(blob)` on the V5 verifier on Base | `verify(blob) on Base: true` |
76
+ | 52 | [arbitration-calls](52-arbitration-calls.mjs) | The three tiers of the ArbitratorRouter as unsigned calls, and what a ruling writes into the record | `findCheated(jobId, loss)` |
77
+ | 53 | [attested-by-default](53-attested-by-default.mjs) | A settle, a grade and a resale step, each with its mark and its calls on Base; the stamp Base lacks said | `missing: GradeStampRegistry@8453` |
71
78
 
72
79
  ## Settings
73
80
 
@@ -0,0 +1,116 @@
1
+ {
2
+ "ok": true,
3
+ "chain_id": 8453,
4
+ "tx": "0x48f87043df02dc8f97c3a70afb8c8748848d0efae865cb251c429cce57bc127f",
5
+ "block_number": 52587000,
6
+ "block_hash": "0xce0c4c585c9d88150cacfec796ab51a5acdb42b8b0570a0da2f90679ba74dbd3",
7
+ "is_finalized": true,
8
+ "proven": true,
9
+ "proof_state": "proven",
10
+ "super_root_hash": "af8134f8fc0de7a2ab4456adcbb847761102065a6e81da26cc5d957435628a04",
11
+ "batch_id": 1791967493,
12
+ "finality_block": 52588585,
13
+ "finalized_block_hash": "0x81a0d70ecfa2132d53e2759bd7b4e5639d43c559727e0d890f788aaf2d6776c1",
14
+ "verifiable_block": 52588585,
15
+ "checks": {
16
+ "receipt_found": true,
17
+ "tx_succeeded": true,
18
+ "proof_served": true,
19
+ "block_hash_matches": true,
20
+ "within_verifiable_range": true
21
+ },
22
+ "source": "receipt read from chain; block proof from the producer; block hash compared between the two",
23
+ "blob": {
24
+ "superroot": {
25
+ "superrootHash": "0xaf8134f8fc0de7a2ab4456adcbb847761102065a6e81da26cc5d957435628a04",
26
+ "batchId": 1791967493,
27
+ "chainCount": 76,
28
+ "totalTwigs": 15664981
29
+ },
30
+ "chainHeaders": [
31
+ {
32
+ "chainId": 8453,
33
+ "chainType": 0,
34
+ "blockNumber": 52587000,
35
+ "blockHash": "0xce0c4c585c9d88150cacfec796ab51a5acdb42b8b0570a0da2f90679ba74dbd3",
36
+ "miniMmrRoot": "0xa6b8213dd9ac171ad580db56a3eb7b640141d227f4b078d62f037f191140f24e",
37
+ "twigCount": 7316750,
38
+ "stateRoot": "0x24d77153e44b43a107b419502d81f114adb3826f02e804c5f51a08dc8de502de"
39
+ }
40
+ ],
41
+ "superrootProof": {
42
+ "targetChainIndex": 4,
43
+ "siblings": [
44
+ "0x0fd49ee3e6a6fbbbd6b84b6f8eaedd1b95866c9bca6e8578acff0a2bd99ef862",
45
+ "0xbd92daadb001856b635ced48ab36e974c4d49591833ae7fda4b5de5acf33ab13",
46
+ "0x508428f519638d847366a67192c9395fde6ddeccc4efa3c7be4d07ac0f54c9d0",
47
+ "0x231add3099e2ad97acbebe11f1f5b09d090a65018f18c3a26b432676dabc2028",
48
+ "0x2ba3594dfe41c71b787e4fd18ef48e35acca24f2e85e5c2bb10cb6e7602a0849",
49
+ "0x5bb6ec61927fec1e96c7ee107f2355ff2ec8e190b0325d6237e68135eb0d2bea",
50
+ "0xa7a60abbcdf5183a8cc8310db3b4c0237639125c5ec3f7e940b4b27e847ace83"
51
+ ]
52
+ },
53
+ "blockProof": {
54
+ "blockIndex": 52587000,
55
+ "siblings": [],
56
+ "l4Status": "block is bound by `inclusion`: its hash folds to miniMmrRoot at index = block number; `siblings` is left empty because the deployed v5.0 verifier folds the snapshot-tip header's hash, not this block's",
57
+ "inclusion": {
58
+ "blockNumber": 52587000,
59
+ "blockHash": "0xce0c4c585c9d88150cacfec796ab51a5acdb42b8b0570a0da2f90679ba74dbd3",
60
+ "index": 52587000,
61
+ "siblings": [
62
+ "0x043b28d01bbca81b36e04c4e7fd726e900e45e574db168ed13579f3a0d3e244f",
63
+ "0x100046450ce4770bae09f3a200cc2bd9ce3de122f090bbb187d3d1b987f73e54",
64
+ "0xe3618ea65f808242ffe9d3d7475dba837c2467554eb751c8efe1556e54f03bda",
65
+ "0xf76ff27d7bd09c305fdf7aa975b77ce0d1a8f3e197dcf6cf54d8c900d07fbf41",
66
+ "0x4d313f8ba598331677b797dea1a5cb1d551f72d10cbabf60b7ac61639246af30",
67
+ "0xe452f8df4808e6c3945417a8acfa6bc110041558b0b4b5570640f08e307464b4",
68
+ "0x8c6deaf63e1ad1f04ae481bcbb85a42aa6da7d9386a3b51bc9d1a56ca40815b6",
69
+ "0x96b5e1394de1d84aaccd42a7dae0ca697853fac22470952aad3d8916a51896fd",
70
+ "0x89b303cd5084be070a694010736650f52a28ba9f5030ca159e2edddc8f9a9f13",
71
+ "0x96c1e34609a7afdb4a4fb41f11a6e00b370e47b0eef7187c3984705f9862461d",
72
+ "0x7760cfe7149aecabfa7bfdf320fcdf140c3281af255143582bf54dd9dbd9aa94",
73
+ "0xbfe49b5957155850e6f748971be706595962973ad2bb635e2514458b3eb3eb4d",
74
+ "0x7765a9828a5f351e4585902b21419f09ef6ed395f8bda308f868267d8bc74921",
75
+ "0xc55a4d3f8b7d145f438028edec83bf2d7651e5f033434808d1d00f32bb1091c7",
76
+ "0x66cfa7c9b1a6bd60caaf2178736d803b8d8a58a7234a01cb0173ff7eb9708745",
77
+ "0xda7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d2",
78
+ "0x2733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981f",
79
+ "0xefc595b82ec8c78a5df2927bbe6bb5a096426f2cb78d20b367831d25a080c648",
80
+ "0x5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0",
81
+ "0xb46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0",
82
+ "0xc65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2",
83
+ "0xb9565c463b5a2ce6e81d5eec6214a825a365276138419083c0e8aa57fc2a25b1",
84
+ "0x5a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e377",
85
+ "0x4df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652",
86
+ "0xb863a0ce7902ee4f773f51c4e0606882d6890e17989bf7c06aa9227fa08546f4",
87
+ "0x0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618d",
88
+ "0xb8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d0",
89
+ "0x838c5655cb21c6cb83313b5a631175dff4963772cce9108188b34ac87c81c41e",
90
+ "0x662ee4dd2dd7b2bc707961b1e646c4047669dcb6584f0d8d770daf5d7e7deb2e",
91
+ "0x388ab20e2573d171a88108e79d820e98f26c0b84aa8b2f4aa4968dbb818ea322",
92
+ "0x93237c50ba75ee485f4c22adf2f741400bdf8d6a9cc7df7ecae576221665d735",
93
+ "0x8448818bb4ae4562849e949e17ac16e0be16688e156b5cf15e098c627c0056a9"
94
+ ],
95
+ "root": "0xa6b8213dd9ac171ad580db56a3eb7b640141d227f4b078d62f037f191140f24e",
96
+ "tipBlockNumber": 52588585,
97
+ "tipBlockHash": "0x81a0d70ecfa2132d53e2759bd7b4e5639d43c559727e0d890f788aaf2d6776c1",
98
+ "twigCount": 7316750,
99
+ "treeVersion": 84269
100
+ }
101
+ },
102
+ "event": {
103
+ "chainType": 0,
104
+ "encoded": "0x"
105
+ },
106
+ "finality": {
107
+ "chainId": 8453,
108
+ "blockNumber": 52587000,
109
+ "finalityType": 12,
110
+ "proof": "0x000000000000000000000000b1d481571395a2f3e6672df8cfaa4331aafa2464c2091dcdd1299851b1321a8ee36ce19b3512a5aeff12b30f9a3409a98f287bec00000000000000000000000000000000000000000000000000000000031ea3680000000000000000000000000000000000000000000000000000000000000002",
111
+ "finalizedBlockNumber": 52588585,
112
+ "finalizedBlockHash": "0x81a0d70ecfa2132d53e2759bd7b4e5639d43c559727e0d890f788aaf2d6776c1"
113
+ },
114
+ "verifiableBlock": 52588585
115
+ }
116
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moonbeam-foundation/sdk",
3
- "version": "0.5.2",
3
+ "version": "0.7.0",
4
4
  "description": "Assurance for agent work: wrap a job in a price, a judge and a deadline, and settle it against proof.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -52,6 +52,38 @@
52
52
  "types": "./dist/judge/index.d.ts",
53
53
  "import": "./dist/judge/index.js"
54
54
  },
55
+ "./assurance": {
56
+ "types": "./dist/assurance/index.d.ts",
57
+ "import": "./dist/assurance/index.js"
58
+ },
59
+ "./resale": {
60
+ "types": "./dist/resale/index.d.ts",
61
+ "import": "./dist/resale/index.js"
62
+ },
63
+ "./x402": {
64
+ "types": "./dist/x402/index.d.ts",
65
+ "import": "./dist/x402/index.js"
66
+ },
67
+ "./proof": {
68
+ "types": "./dist/proof/index.d.ts",
69
+ "import": "./dist/proof/index.js"
70
+ },
71
+ "./arbitration": {
72
+ "types": "./dist/arbitration/index.d.ts",
73
+ "import": "./dist/arbitration/index.js"
74
+ },
75
+ "./rpc": {
76
+ "types": "./dist/rpc/index.d.ts",
77
+ "import": "./dist/rpc/index.js"
78
+ },
79
+ "./attest": {
80
+ "types": "./dist/attest/index.d.ts",
81
+ "import": "./dist/attest/index.js"
82
+ },
83
+ "./abi": {
84
+ "types": "./dist/abi/index.d.ts",
85
+ "import": "./dist/abi/index.js"
86
+ },
55
87
  "./package.json": "./package.json"
56
88
  },
57
89
  "files": [
@@ -74,7 +106,16 @@
74
106
  "test:watch": "vitest",
75
107
  "test:coverage": "vitest run --coverage",
76
108
  "lint": "tsc --noEmit && vitest run --reporter=dot",
77
- "prepublishOnly": "npm run build && npm test"
109
+ "prepublishOnly": "npm run check",
110
+ "postbuild": "node scripts/postbuild.mjs",
111
+ "gen:registry": "node scripts/gen-moonbeam-acp.mjs",
112
+ "check:registry": "node scripts/gen-moonbeam-acp.mjs --check",
113
+ "check:pins": "node scripts/check-pins.mjs",
114
+ "check": "npm run typecheck && npm run build && npm test && npm run check:pins",
115
+ "sync": "node scripts/sync.mjs",
116
+ "check:sync": "node scripts/sync.mjs --check",
117
+ "test:fork": "node test/fork/run-fork.mjs",
118
+ "test:live": "LIVE=1 vitest run test/live.test.ts"
78
119
  },
79
120
  "keywords": [
80
121
  "moonbeam",
@@ -93,16 +134,16 @@
93
134
  "erc-8183"
94
135
  ],
95
136
  "devDependencies": {
96
- "@types/node": "^22.20.0",
97
- "@vitest/coverage-v8": "^4.1.8",
98
- "typescript": "^5.7.3",
99
- "viem": "^2.55.19",
100
- "vitest": "^4.1.8"
137
+ "@types/node": "^22.20.5",
138
+ "@vitest/coverage-v8": "^5.0.4",
139
+ "typescript": "^7.0.2",
140
+ "viem": "^2.57.6",
141
+ "vitest": "^5.0.4"
101
142
  },
102
143
  "dependencies": {
103
- "@taifoon/jev": "^0.2.13",
104
- "@taifoon/jev-wilson": "^0.2.0",
105
- "@taifoon/n8n-nodes-typesafe": "^2.0.4"
144
+ "@taifoon/jev": "^0.3.0",
145
+ "@taifoon/jev-wilson": "^0.3.1",
146
+ "@taifoon/n8n-nodes-typesafe": "^2.0.5"
106
147
  },
107
148
  "bin": {
108
149
  "moonbeam": "bin/moonbeam.mjs"
@@ -11,7 +11,7 @@ Capital you put into a pool stands behind other people's work. When an adjudicat
11
11
  provider cheated, the provider's deposit is consumed first and **your pool pays
12
12
  whatever the deposit cannot**. That is the risk, and it is not optional once you
13
13
  have backed a pool — the exposure *is* the yield. There is no passive tier, because
14
- rewards come from real fees rather than from newly minted tokens.
14
+ rewards come from fees paid rather than from newly minted tokens.
15
15
 
16
16
  You are **not** charged when work is merely graded bad. A rejection refunds the
17
17
  client and returns the deposit; the pool pays nothing.
@@ -37,7 +37,7 @@ import { foldTasks, findSelfGraded, independentShare, decodeAcpLogs } from '@moo
37
37
 
38
38
  const states = foldTasks(decodeAcpLogs(logs));
39
39
  findSelfGraded(states); // verification 'self' or 'none'
40
- independentShare(states); // how much of the population had a real judge
40
+ independentShare(states); // how much of the population had an independent judge
41
41
  ```
42
42
 
43
43
  On live agent-commerce traffic, independently graded jobs are a tiny fraction of
@@ -21,7 +21,7 @@ doubtQuote(terms, usdc('30'), 34);
21
21
  ```
22
22
 
23
23
  `breakEvenProbability` is the failure rate at which the position is EV-neutral.
24
- Take it only if you believe the real failure rate is higher than the fee implies.
24
+ Take it only if you believe the failure rate is higher than the fee implies.
25
25
 
26
26
  ## The cap you must check before sizing
27
27
 
@@ -49,7 +49,7 @@ livenessOf(state, clock) // nobody can be locked out (see below)
49
49
  **No lockout.** A silent counterparty can never strand someone's money. Past the
50
50
  deadline the refund is *permissionless* — anyone may trigger it — and either
51
51
  party may escalate to arbitration at any time. `livenessOf()` checks this
52
- against real state instead of asking you to trust it.
52
+ against the chain's state instead of asking you to trust it.
53
53
 
54
54
  ## Do not claim
55
55