Inspiration
Earlier this month I read Anthropic's FlashProve paper on provable inference and presented it to my club, Blockchain at Berkeley. The paper shows a model provider can prove which model produced a response, so someone paying for one model can check they weren't actually served a cheaper one. At the same time, nowadays everyone is talking about letting AI agents spend money, and the question that keeps coming up is trust. Using a zkSNARK, a cryptographic proof, to make sure a model API is trustworthy before an agent is able to pay seemed like an interesting solution.
What it does
zkReceipt is a payment layer for AI agents that buy model inference. The agent pays through x402, but the USDC goes into an escrow contract on Arc instead of to the provider. The provider has to send each answer with a zkSNARK proving that its committed model, run on the agent's prompt, produced it. If the proof checks out, the provider gets paid. If it doesn't, the contract refunds the agent and slashes the provider's bond. The same proof covers more than overpaying. It stops an attacker from swapping in a tampered model that an agent then trusts with money and it lets safety evaluators check that the model they tested is the one being served to customers.
How I built it
The provider commits to a hash of its model weights in my ReceiptEscrow contract on Arc and locks up a USDC bond. The agent pays through x402, but the USDC goes into escrow instead of to the provider. The provider runs its model with EZKL and posts the answer along with a proof. The agent checks the proof for free with an eth_call. If it fails, the agent challenges, and the contract runs the verifier itself, refunds the agent and slashes half the bond. If nobody challenges within 60 seconds, the provider gets paid. For the demo the model scores how risky a wallet is. The agent builds the prompt (7 numbers about the wallet's USDC history) from a QuickNode Stream of Arc transfers that I index on Vercel and Neon. Every job gets a receipt page where anyone can re-run the proof check in their browser. The model and provider are Python (PyTorch, ONNX, EZKL, FastAPI), the contracts are Solidity with Foundry, the agent is TypeScript with viem, and the receipts are a Next.js app.
Challenges I ran into
The biggest one was that FlashProve itself is far too heavy for a hackathon. Its proofs are around 19 MB per 1,024-token request and take a large GPU to make, so I used EZKL (a lighter alternative) with a small model. The escrow only cares about a model fingerprint and a verifier, so a lighter LLM proof could slot into the same contract later. Another challenge is that I realized a buyer could try to make an honest proof look like it failed by giving the verifier too little gas, and walk off with the bond. To mitigate this, I made it so that the contract calls the verifier with a fixed gas budget so that doesn't work.
Accomplishments that I'm proud of
The whole loop runs for real on Arc testnet: payment, proof, verification, challenge, refund and slash are all real transactions you can open on the explorer. I gave the provider four modes (honest, editing the score after proving, swapping in a cheaper model, and changing the agent's prompt) and ran all of them against Arc. The three cheating modes all got slashed onchain, and the honest one got paid. A full onchain proof check costs about 0.02 USDC, which makes verifying every paid answer cheap enough to be worth it.
What I learned
A zkSNARK only means something together with its public inputs. I had to keep the model commitment, the prompt and the output in the contract's storage and rebuild them at challenge time, instead of trusting whatever the caller passes in. I also learned that "paid" and "verified" are different things: a job nobody challenges gets paid even if its proof is bad, which is why the receipt pages run the check themselves.
What's next for zkReceipt
- LLM-sized proofs. FlashProve shows they're possible, but at about 19 MB per 1,024 tokens they're too big to check on a chain. A small wrapper proof around them would plug into the same escrow, since the contract only needs a model fingerprint and a verifier.
- Watchers that challenge bad jobs for agents that don't verify and earn part of the slashed bond.
- An x402 escrow scheme other providers can adopt for any answer they can prove.
Built With
- arc
- eip-3009
- ezkl
- fastapi
- foundry
- halo2
- neon
- next.js
- onnx
- postgresql
- python
- pytorch
- quicknode-streams
- solidity
- typescript
- usdc
- vercel
- viem
- x402
- zksnark