About
Imagine giving your AI agent 10 QOR and telling it to go hire another agent to clean some data. How do you stop it from spending 100? How does the other agent know it'll actually get paid? And if someone steals your agent's key, what's left?
Right now the honest answer is: you can't, it doesn't, and nothing. Agents are already starting to pay each other, but the "safety" is usually a spending limit written into the agent's own code and a private key sitting in an env file. If the agent gets prompt-injected or the key leaks, the money's gone. And those keys are the same kind a quantum computer is expected to break, so funds sitting in agent wallets are the obvious thing to go after.
Treaty is my attempt at fixing that properly.
Agents (or people, or a mix) write down the deal: what the work is, the price, who gets paid and how it's split. Every party signs those exact terms with a post-quantum ML-DSA-87 key, and the contract on QoreChain checks each signature itself before the deal goes live. The client then locks the whole budget in the contract, so the agents doing the work can see the money is there before they lift a finger.
When work comes in, only its hash goes on chain. The client accepts it and the providers get paid automatically, split the way they agreed. If it's bad, the client rejects it and pays nothing. And if the client just disappears and never reviews it, the payment releases itself once the review period is over, so nobody gets left hanging.
The part I care about most is the human behind the agent. The owner sets limits that live in the contract, not in the agent: the most it can spend per deal, the most in total, and when its permission runs out. A hacked agent still can't go past them. The owner can also switch the agent off at any time, and whatever budget it didn't spend comes back to the owner, not the agent.
And a stolen key isn't enough to do anything. Withdrawing, delivering work, approving it, all of it needs the post-quantum key too. Someone holding just the normal wallet key, whether they stole it today or cracked it with a quantum computer later, gets nothing.
I didn't want this to be a slide deck, so I ran the whole thing live on the Diana testnet on 26 November. Olivia gives her research agent a budget: 10 QOR per deal, 15 total, 7 days. Her agent hires a data agent and a cleaning agent (80/20) to clean five datasets at 2 QOR each. They all sign, and it locks 10 QOR. One dataset is good and gets paid, 1.6 and 0.4 QOR. One is junk and gets rejected. One gets ignored and pays out by itself after the review window. Then her agent tries to commit to a second deal beyond what Olivia allowed, and the contract says no. An attacker grabs the data agent's wallet key and tries to withdraw. Refused on chain. Olivia switches her agent off, and after the deadline the unused 4 QOR goes back to her.
That was 18 real transactions and none failed. Every one is linked in the README.
There's also a web app (treatyv1.vercel.app) where you can follow every deal live. People see a plain sentence like "Treaty: accept delivery 0 of treaty #3" instead of a wall of hex, so they know exactly what they're agreeing to. Deliveries can travel sealed with QoreSeal (ML-KEM-1024), so only the client can read the work.
Agents shouldn't have to trust each other to do business. With Treaty they don't have to.
How it's made
Treaty didn't start out as Treaty. The first version was called QoreSplit, a checkout link that split each payment between collaborators. Then I added a rule that nobody could be put on a split without signing the terms with their post-quantum key. Somewhere around there it clicked that the people who need this most aren't people. They're AI agents paying each other for work. So I rebuilt it around that.
The core is one Solidity contract, deployed on QoreChain Diana. Every action that commits someone or moves money (accepting terms, delivering work, approving or rejecting it, withdrawing, an owner setting limits or switching an agent off) has to come with an ML-DSA-87 signature, and the contract checks it on chain using QoreChain's pqcVerify precompile. The contract doesn't take your word for which key is yours. It looks the key up in the chain's own registry with pqcKeyStatus, and that key needs a proof of possession. Each signature also covers the chain, the contract and exactly what's being approved, so it can't be reused anywhere else. There's deliberately no way to withdraw with just a normal wallet key.
Every agreement and every payment also writes a receipt on QoreChain Native through the Cross-VM bridge, in the same transaction. If the Native side fails, the whole thing reverts, so the two chains never tell different stories.
On top of that, each agent runs inside its own scoped EVM window. The window can only call the Treaty contract, and it has a cap on transactions, on value and on how many blocks it stays open. So an agent is boxed in three ways: by its window, by the limits its owner set in the contract, and by the terms of the deal itself.
Agents talk to the contract through a small SDK. Before an agent signs anything, the SDK rebuilds the exact message from what's on chain and refuses if it doesn't match. It also checks that the agent's key matches the registry and that its window will still allow the transaction, so you find out before you send, not after.
People use the web app (Vite and viem, live at treatyv1.vercel.app). They sign with the Treaty signing tool, and in the browser with QoreX as soon as QoreX supports message signing (the app detects it). Deliveries can be encrypted to the client with QoreSeal (ML-KEM-1024); only the hash goes on chain, and the client checks the data against it.
Kits and features used: the pqcVerify and pqcKeyStatus precompiles, the Cross-VM bridge with the Native receipt book, scoped EVM windows, QoreX and QoreSign signing, @qorechain/sdk, @qorechain/evm, @qorechain/qoresign and viem. Hardhat and Playwright for testing.
What was hard
Getting the bytes to match. The same message has to come out identical in Solidity, in the SDK and in the browser, down to the last byte, or a perfectly good signature fails. I ended up writing tests that compare the contract's bytes with the SDK's for every type of signature, signed with real ML-DSA-87 keys.
Testing without the real chain. No local EVM has QoreChain's precompiles, so I built a local stand-in for Diana whose pqcVerify only accepts a signature after actually checking it with real ML-DSA-87. The end-to-end tests run the real deploy script, the signing tool and the web app in a real browser against it.
Diana surprised me a few times. The RPC caps gas estimates at 5 million, and a single pqcVerify costs around 315,000. Simulating calls with state overrides quietly switches the precompiles off. And deploying needs an account whose window allows creating contracts. None of that showed up locally, only when I ran checks against the live testnet, so I changed the tooling to handle each one.
The browser couldn't read Native at all, because Diana's Native API doesn't send CORS headers. I added two small read-only routes on the app's own domain so the web app can still verify receipts.
The owner limits took the most thought. They have to hold even if the agent's own code is compromised, so they live in the contract, need both the agent and the owner to sign, and get checked twice: when the agent agrees to a deal and when the budget is locked. While auditing my own code I found a real bug there. Anyone could lock a client's budget, but refunds went to the client, so a stranger could lose money. Now only the client or its owner can lock a budget, and there's a test for it.
How I know it works: npm test covers the contract's rules, npm run e2e runs the whole product end to end, and I ran the full story live on Diana on 26 November. That was 18 transactions from four separate accounts, and none failed. The stolen-key attack was refused with BadPqcSignature, overspending with MandateLimitExceeded, and the switched-off agent with AgentNotAuthorized. It's all in deployments/diana-demo.json.
I built Treaty with Claude Code as my AI coding agent. I made the calls on what to build and checked everything against tests and live runs, and it wrote most of the code. AI_USAGE.md has the full story.