Skip to content

Receipts

Every execution produces a receipt. Its hash covers only consensus fields (no timestamp, no node id), so every honest node computes the same hash for the same call.

receipt_hash = keccak256(canonical_json({
"v": 1,
"module_address": "0x…", // lowercase
"function": "name",
"input_hash": "0x…", // keccak256(raw input bytes)
"output_hash": "0x…", // keccak256(raw output bytes); empty output on failure
"events_hash": "0x…", // keccak256(canonical_json([{"name","data"}, …])), [] on failure
"gas_used": 1234,
"success": true
}))
  • The error string of a failed call is informational and not hashed.
  • A node signs "necter-receipt-v1:" + receipt_hash with its ed25519 key. The signed envelope carries the receipt, node_id, public_key, timestamp and signature.
  • node_id = "ndsr-" + the first 16 hex characters of keccak256(public key).

Given an output you received and the receipt hash a quorum agreed on, you can check:

  1. input_hash == keccak256(the input you sent) and output_hash == keccak256(output).
  2. Recompute receipt_hash from the fields with canonical JSON and Keccak-256.
  3. For direct calls (/v1/execute) the response lists the agreeing validators. For committee tasks, GET /v1/explorer/rounds/{round_id} and GET /v1/explorer/receipts/{receipt_hash} show the votes and the validators’ finality record.
  4. Or re-run it: ndsr run module.hbc fn --input '…' gives the same receipt_hash for a stateless call.
import json
from eth_hash.auto import keccak # pip install "eth-hash[pycryptodome]"
def h(b: bytes) -> str:
return "0x" + keccak(b).hex()
def canonical(o) -> bytes:
return json.dumps(o, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode()
receipt = {
"v": 1, "module_address": "0x…", "function": "work",
"input_hash": h(input_bytes), "output_hash": h(output_bytes),
"events_hash": h(canonical(events)), "gas_used": gas_used, "success": True,
}
assert h(canonical(receipt)) == receipt_hash

When a call is signed, or when the module reads the context (ctx.caller, ctx.origin, ctx.time, ctx.kind, ctx.round_id, ctx.call_id or ctx.network), the receipt becomes v: 2 and gains a context_hash:

context = {"v": 1, "network", "kind", "time", "round_id", "origin", "call_hash"}
context_hash = keccak256(canonical_json(context))
receipt_hash = keccak256(canonical_json({
"v": 2, "module_address", "function", "input_hash", "output_hash", "events_hash",
"gas_used", "success", "context_hash"
}))

All context fields are always present, with "" for absent strings. The full context object is returned next to the receipt, so you can recompute context_hash and read who signed the call (origin). For example, for the eip191 call of the signed calls guide:

{
"v": 1,
"network": "necter-testnet",
"kind": 1,
"time": 1760000004,
"round_id": "exec:0x23f8fc2177f677d687f137d29bece3ede1d7371374b7558c3153d253527afcc7",
"origin": "0x4a62316623ad457f02cdc5d997ded67a383ec569",
"call_hash": "0xcd40d2a49ce0100cc3516c655537fa8a425693f73a4e5ddf7871e58305ae44b6"
}

has context_hash = 0x652590fcb914f59f51d0c54faddfe965cf5eeff2d592e0dd299f6fdda9a687e2.

  • Events with topics (hive.emit_indexed) are hashed as {"name", "topics", "data"}; topics is omitted when there are none, so the events_hash of every existing event is unchanged.
  • A signed call’s call_hash is part of the round id, so the Hub cannot send different envelopes to different validators under one round.
  • A signed call that fails after its nonce check still commits its nonce write: its vote reports the module’s state seq advancing by one. Unsigned failures still commit nothing.
  • Every other execution keeps its v1 receipt byte for byte, except that crypto.hash is repriced, which changes gas_used.

Receipts are what nodes vote on:

Round id Who votes Where
exec:0x… Validators Direct calls (/v1/execute) and validator fallback
task:0x… Committee miners, then validators sign a finality vote Mining projects
epoch:<project>:<epoch>:<attempt> Validators Per-project reward receipts

A vote also carries a round signature over a short text (for example necter-vote-v1\ntask\n<round_id>\n<receipt_hash>\n<payout_address>), binding the vote to one round and one payout address so it cannot be replayed. Two votes from one key in one round with different receipt hashes are equivocation, which is provable and slashable. Slashing