Metering rules, version 1
- Engine: QuickJS compiled to WebAssembly (quickjs-emscripten 0.32.0, @jitl/quickjs-wasmfile-release-sync). The browser, the hosted runner and examples/runner.mjs load the same build.
- One compute unit (CU) is one QuickJS interrupt check, which the engine makes about every 5,000 loop iterations or calls. The count depends on the script, the input and the attempt, not on the machine.
- Each attempt gets a fresh sandbox: 32 MiB memory, 512 KiB stack, no network, no files, no timers. Math.random is seeded from the script hash, input hash and attempt number; the clock is frozen at 2026-01-01T00:00:00.000Z.
- The script defines
main(input, ctx);ctx= attempt, maxAttempts, allowance, lastError. Return values must be JSON, at most 8,192 characters; console.log keeps 50 lines. - Allowance of an attempt = min(cap per attempt, budget left). Past it, the attempt is Halted and charged exactly the allowance (a script cannot catch the halt). A throw = Failed, charged what it used. A return = Succeeded. Minimum charge 1 CU.
- The task stops at the first success, when the budget is spent, or after the last allowed attempt.
- Output hash = keccak256 of canonical JSON {status, value or error, log}. Duration is wall time, signed but not deterministic, so it is never compared.
The receipt
EIP-712 domain: name "RetriqReceiptBook", version "1", chainId 99901, verifyingContract = the book
Receipt(uint256 taskId, uint32 attempt, bytes32 scriptHash, bytes32 inputHash,
uint64 computeUnits, uint128 cost, uint8 status, bytes32 outputHash,
uint32 durationMs, address runner)
status: 1 Succeeded, 2 Failed, 3 Halted cost = computeUnits x pricePerUnit (wei of HYPE)What RetriqReceiptBook enforces
- openTask publishes the script (up to 12,288 bytes) and input (up to 4,096) in the TaskSource event and stores their hashes, the runner, the budget (up to 10,000,000 CU), the cap per attempt, 1 to 16 attempts, the price and a deadline 10 minutes to 30 days away. The HYPE sent must equal budget x price.
- submitReceipts accepts up to 16 receipts, each the next attempt in order, signed by the task's runner (low-s ECDSA, no malleable twins), with matching hashes, units within the allowance, cost = units x price, and Halted only at exactly the allowance. Anyone may relay them.
- A success marks finalAttempt and ends the task. Running out of budget or attempts ends it as Exhausted. The unspent escrow becomes the developer's; each recorded cost becomes the runner's. Both withdraw it themselves.
- Refusals are explained before anything is sent: checkOpen and checkReceipt return the same reason bits the transaction would revert with.
Every power, by role
- Developer: opens the task; may close it early, which ends receipts after a 15 minute grace so the runner can still record work already done; may contest a recorded attempt (a public note, no funds move, cannot be undone); withdraws refunds.
- Runner: fixed at open, cannot be changed. Its signature is the only way to record an attempt, within the rules above. Withdraws its pay.
- Anyone: relays signed receipts, settles a task after its deadline, reads everything, re-runs the published script.
- Nobody: no owner, admin, pause, fee or upgrade. A recorded attempt cannot be removed and its pay cannot be taken back; escrow leaves only as runner pay or developer refund.
What this does not claim
- A receipt proves who signed it. Whether its numbers are true is checked by running the script again (the verifier does this); a self-signed receipt is only as honest as its signer until someone re-runs it.
- CU are not seconds. The credits page shows how long they take on your device.
- The contract is new: start with small budgets.
- $RETRIQ credits are a Concept.
Run it outside the browser
# your own runner key, in your shell only (never a funded treasury key) export RUNNER_PRIVATE_KEY=0x... node examples/runner.mjs --task 7 # run task 7, print signed receipts as JSON node examples/runner.mjs --task 7 --submit # also record them (the runner key pays gas)
Contract: not deployed yet · Proof: /api/proof · Health: /api/health