Verify a receipt
Recompute a receipt leaf and its Merkle path, then compare with the root posted on chain.
Hourly roots
- ScreenSettlement
- ActionRoot per hour
- ResultMemo on chain
Open ProofHourly roots with their memo transactions
Example dataAfter each UTC hour, settlement builds a Merkle root over that hour's successful calls and posts it as a memo ec:receipts:{hour}:{root}:{count}. Until then root, proof and memoTx are null.
Recompute it yourself
- ScreenleafFields
- ActionHash and path
- ResultMatches the root
Check the Merkle proofIncluded in the posted hourly root
Example dataLeaf = sha256 of the canonical JSON of leafFields (keys sorted, no spaces). Each parent = sha256(min(a, b) || max(a, b)) on raw bytes; an odd node moves up unchanged.
// Recompute a receipt's leaf and root (BACKEND.md 8.5). Node 22+.
import { createHash } from "node:crypto";
const sha256 = bytes => createHash("sha256").update(bytes).digest();
const canonical = value => Array.isArray(value)
? `[${value.map(canonical).join(",")}]`
: value && typeof value === "object"
? `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonical(value[key])}`).join(",")}}`
: JSON.stringify(value);
const receipt = await (await fetch(process.env.RECEIPT_URL)).json();
const leaf = sha256(canonical(receipt.leafFields));
if (leaf.toString("hex") !== receipt.leaf.replace(/^0x/, "")) throw new Error("leaf mismatch");
let node = leaf;
for (const sibling of receipt.proof ?? []) {
const other = Buffer.from(sibling.replace(/^0x/, ""), "hex");
node = Buffer.compare(node, other) <= 0 ? sha256(Buffer.concat([node, other])) : sha256(Buffer.concat([other, node]));
}
console.log(node.toString("hex") === receipt.root.replace(/^0x/, "") ? "included in root" : "root mismatch");What it does and does not prove
- ScreenRoot on chain
- ActionYour line included
- ResultMeter is the platform
Check the Merkle proofIncluded in the posted hourly root
Example dataInclusion proves your receipt was in the posted set and unchanged. The token counts themselves come from the platform meter.
In the product: Open Proof