A local Hedera network in one 10 MB binary, with a coding-agent harness and an x402 rail built in.
hanvil is a local Hedera network that runs as a single 10 MB binary. It serves JSON-RPC (7546), mirror node REST (5551) and HAPI gRPC (50211) from one in-memory chain, on the same ports and with the same 30 pre-funded accounts and keys as hiero-local-node, so @hiero-ledger/sdk, viem, hardhat and foundry connect without config changes. First JSON-RPC answer 6 ms after exec, 5.8 MB resident.
Why: hiero-local-node is 18 containers, 3.8 GB of RAM and about 50 s to boot, and it is deprecated as of this month. Its replacement, Solo, runs on Kubernetes and wants 12 GB of RAM and 6 cores. hedera-harness, Hedera's coding-agent harness, only runs against testnet, so every agent attempt costs HBAR and a network round trip, and a failed attempt leaves state behind for the next one.
What is in the binary:
hanvil_rejections: transactions Hedera refuses at precheck (duplicate transaction id, bad signature, expired valid-start window, and so on) never reach consensus, so on a real network they produce no record, no receipt and no mirror row. hanvil is the node, so it keeps them and exposes them over JSON-RPC as hanvil_rejections. The demo replays an x402 payment header and reads the DUPLICATE_TRANSACTION refusal back from that list. Recipes can also assert on decoded contract events and advance the chain clock between assertion sets.
Numbers, same M-series Mac, hanvil vs hiero-local-node:
Upstream: PRs #47 and #48 to hedera-dev/hedera-harness add network: "local" (run CHAIN against a local node) and per-attempt chain snapshots. Both are open. The demo runs the upstream TypeScript harness with those two PRs applied, green on hanvil.
Not emulated: consensus, gossip, staking, the real fee schedule (flat 10,000 tinybar per HAPI transaction, 71 tinybar per unit of EVM gas), and HAPI bodies beyond the six implemented (the rest return NOT_SUPPORTED). The full list of 35 declared gaps is in the README under "What is emulated, and what is not".
Rust. One Chain struct behind a RwLock. The JSON-RPC, mirror and gRPC listeners, hanvil run and hanvil toll all take the same lock, so a transfer submitted over JSON-RPC is visible from the mirror endpoints immediately. evm_snapshot clones the struct, evm_revert swaps it back. Nothing holds the lock across an .await.
Crates: revm (EVM), alloy (ABI decoding, sender recovery), axum (the HTTP listeners), tonic + prost (HAPI gRPC over 130 vendored Hedera .proto files), clap, serde_yaml_ng (recipes), regex (secret scan). The node makes no outbound network calls.
Hedera details that took the most work:
x402: on Hedera an x402 payment is a CryptoTransfer the client signs and the facilitator co-signs and submits as fee payer. hanvil toll implements the facilitator (:4020) and a metered service (:4021) against the in-process chain: 100000 tinybar per call, payer 0.0.1002, payTo 0.0.1003, feePayer 0.0.1004. The same code, pointed at testnet, is deployed on Railway (examples/toll, Dockerfile in the repo). The demo makes one paid request there and shows the receipt on HashScan.
Harness: hanvil run reimplements hedera-harness's five stages. GENERATE spawns the agent CLI with the PRD as its prompt. ASSERT checks required and forbidden files, runs the static validators and the secret scan. CHAIN runs the recipe's deploy commands, optionally advances the chain clock, then evaluates the assertions against the Chain struct. SMOKE starts the app's dev server and drives it with @playwright/mcp in headless Chromium. EVALUATE runs a validator agent with the same MCP server. Subprocesses run in their own process groups so Ctrl-C kills the agent, the dev server and the browser together. Every attempt dumps chain state to logs/chain-state-attempt-N.json, and hanvil --state <file> boots from it. The signer's private key is written as <redacted by hanvil> in every prompt file.
Process: solo, first commit 2026-09-07, written with Claude Code. The rules the code was held to are in .claude/CLAUDE.md (one Chain, one lock; ids as newtypes; no unwrap under src/; clippy -D warnings) and a pre-commit hook enforces them. Every commit carries a Co-Authored-By: Claude trailer. docs/research.md pins each claim about upstream behaviour to a file and line. CI runs cargo test on ubuntu and macos, runs the upstream TypeScript harness's CHAIN tier against hanvil with no secrets, and fails if median boot goes over 100 ms.

