If you want to withdraw from Tornado Cash privately, you withdraw to a brand-new wallet with no history. But that wallet has no ETH, so it can't pay the gas for its own withdrawal. Today the answer is a relayer: an off-chain server that sends the transaction for you and takes a fee. It works, but the relayer sees your IP address, can log you, can refuse to serve you, and can be shut down. The one part of the privacy flow that isn't trustless is the part that touches the network.
Unrelayed removes the relayer. Instead of a server, a staked smart contract called TornadoExit sends every withdrawal itself. It uses EIP-8141 frame transactions and the ERC-8421 alternative mempool. A withdrawal is a single transaction whose sender is TornadoExit, and it has two frames:
- A verification frame, where TornadoExit decides whether to pay. It checks the Tornado zero-knowledge proof. It reads Tornado's state to confirm the Merkle root is known and the note isn't spent. It checks that the transaction has exactly the expected shape, that it names TornadoExit as the relayer, and that the fee covers the worst-case gas cost. Only if everything passes does it approve paying for the transaction.
- An execution frame, which calls the normal, unmodified Tornado withdraw, with TornadoExit as the relayer. Tornado pays the 0.1 ETH (minus the fee) to the fresh wallet and pays the fee back to TornadoExit. So TornadoExit gets its gas back plus a small margin on every withdrawal: about 0.0014 ETH per withdrawal in our tests.
The user only generates the proof on their own machine and picks any fresh address. They don't sign anything, they don't need any ETH, and no server is involved.
Why this only works on the alternative mempool:
- Gas: verifying the proof takes about 260k gas of validation, but the canonical EIP-8141 mempool allows 100k.
- Storage: the check has to read Tornado's storage, which the canonical mempool forbids. ERC-8421 allows both for a staked entity, so TornadoExit is staked in the ERC-8421 registry.
- Duplicates: the transaction's nonce key is the note's nullifier hash. Two attempts to spend the same note land in the same mempool slot, so the mempool itself refuses the duplicate. Spammers can't make TornadoExit pay for failed attempts or damage its reputation.
What we showed on the public devnet, against the real Tornado 0.1 ETH pool, with real proofs:
- a withdrawal to a never-used wallet, with TornadoExit paying the gas;
- the same transaction rejected by the canonical mempool;
- an unstaked copy of the contract rejected;
- a duplicate spend refused;
- 15 kinds of malformed transactions (wrong relayer, low fee, bad proof, extra frames and so on) rejected before TornadoExit pays anything.
The full suite runs end to end on the devnet, and every test with its transaction hashes is logged in the repo.
Along the way we found a few things about the devnet:
- The predeployed pool uses its original 2019 verifier, so you need the matching v2.0 proving key.
- Its verifier uses a gas pattern the mempool bans, so we wrote a validation-safe copy of the same verifier for the check.
- The mempool won't let you read an empty account's code during validation. A recipient that reverts on receive could therefore make one withdrawal fail, but the nonce-key design limits that to one failed attempt per note.
Limitations, honestly:
- The anonymity set on the devnet is tiny.
- You still need Tor or a private RPC to hide your IP from the node you submit to.
- Frame transactions aren't on mainnet yet.
The design isn't specific to Tornado: it works for any Merkle-tree privacy pool that pays a relayer fee, and Railgun is the natural next target.
The stack
- Contracts: Solidity 0.8.28 with Foundry.
- Frame opcodes: to use EIP-8141 from Solidity I used @forshtat/hegota-support. It wraps APPROVE, TXPARAM, FRAMEPARAM and FRAMEDATACOPY as small Yul helper contracts that my contract deploys and calls. Its TypeScript codec handles the devnet's frame-transaction format.
- Client: TypeScript and viem.
- Prover: a separate Node 16 package using the original 2019 Tornado proving stack (circomlib, snarkjs, websnark's WASM Groth16 prover, fixed-merkle-tree). It's a straight port of tornado-cli's note, tree and proof logic.
- Network: everything runs on the public EIP-8141 devnet: ethrex as the execution client, and the ERC-8421 sidecar as the alternative mempool.
How the pieces fit
TornadoExit is the staked contract that sends every withdrawal. To withdraw, the client:
- rebuilds Tornado's Merkle tree from the pool's Deposit logs over plain RPC;
- quotes the fee (explained below);
- asks the Node 16 prover (a child process, JSON in and out) for a Groth16 proof with TornadoExit as the relayer;
- builds a two-frame transaction: a VERIFY frame calling TornadoExit.verifyWithdrawal(), and a SENDER frame calling Tornado's withdraw. Its nonce key is the note's nullifier hash;
- submits it with eth_sendFrameTransaction.
In VERIFY, TornadoExit:
- introspects the transaction: frame count, frame 1's target, value, flags and gas limits, the exact withdraw calldata, and the nonce key;
- reads Tornado's root history and nullifier map;
- verifies the proof, then checks its own balance;
- only then calls APPROVE.
What the alternative-mempool stack gave me
- Room for the check: a 1M-gas validation budget and read access to other contracts' storage once TornadoExit was staked in the ERC-8421 registry. The design isn't possible without those.
- Deduplication for free: keyed nonces mean two withdrawals of the same note collide in the mempool.
- Debugging help: the sidecar's admission reports and explorer showed exactly which rule rejected a transaction and for which entity, which saved hours.
The hacky parts
- Probing the mempool from inside VERIFY. You can't log from a validation frame, so I wrote probe contracts that take an expected value as calldata and require(actual == expected). Admission means the value matched, rejection means it didn't. That's how I confirmed every TXPARAM and FRAMEPARAM value, the 256-bit nonce-key limit, stake-gated storage reads and SELFBALANCE, and how duplicates behave, all before writing the real contract.
- Finding the right proving key. Proofs from tornado-cli's key verified locally but failed against the devnet's Tornado Verifier. I decoded the verifying-key points from websnark's binary proving-key format (Montgomery form) and compared them with the PUSH32 constants in the deployed Verifier's bytecode. The pool turned out to be the original December 2019 deployment, which matches the tornado-core v2.0 key, not the later post-ceremony one. That key also only proves correctly with the websnark commit v2.0 itself used, so the prover pins that commit and checks the circuit files by sha256.
- A validation-safe copy of Tornado's verifier. The deployed Verifier calls the pairing precompiles with staticcall(sub(gas, 2000), …). The mempool bans GAS unless it's immediately followed by a CALL, so I wrote a copy with the same verifying key and the same input parsing that uses staticcall(gas(), …). To be sure it's really the same:
- a script disassembles the deployed bytecode and checks that all 28 key constants appear, in order;
- another fails the build if any GAS opcode isn't directly followed by a CALL;
- I compared the two verifiers on real and deliberately broken proofs, and they agree in every case.
- Fee quoting before the proof exists. The fee is one of the proof's public inputs, but the fee depends on the transaction's maximum gas cost, which depends on the calldata, which includes the proof. I break the loop by simulating the same transaction shape with every unknown calldata byte non-zero. That gives an upper bound on the cost; I add 10% and prove with that fee.
- Gas minimums from binary search. For a withdrawal that creates a new account and a new storage slot, ethrex reports about 307k gas used but fails with any limit below about 482k. I found the real minimum by binary-searching the frame's gas limit with ethrex_simulateFrameTransaction. TornadoExit refuses any transaction that gives the withdrawal frame less than that minimum plus a margin, so nobody can make it pay for an out-of-gas revert.
Testing
There are no mocks: every test runs against the live devnet with real deposits and real proofs. The end-to-end suite runs 77 checks covering the happy path, every malformed-transaction case, duplicate spends, the canonical-mempool and unstaked rejections, and fee accounting. It passes repeatedly.