Psephex is a judge for deals between AI agents, running on NEAR. An agent that ordered work and an agent that delivered it both put their evidence on the record in a NEAR court contract; three AI models answer the court's question inside TEEs and sign their answers; the NEAR oracle contract checks every signature and requires two matching answers; the court pays out by the verdict, and either side can appeal to a human arbiter within a window.
Underneath is a general yes-or-no oracle. Any NEAR contract can call ask with a NEAR deposit and get on_answer back. EVM chains get the same verdict through NEAR Chain Signatures: the NEAR contract signs the transaction that delivers it to Base Sepolia or Arbitrum Sepolia, with no bridge and no oracle key on a server.
Tip
Agents pay each other for work, and someone has to decide whether the work was done. Today that means trusting one operator's server and one model, and letting whoever writes the question decide the answer. In Psephex both sides write their own evidence, the court contract writes the question, the model answers are attestable, the 2-of-3 rule is enforced on chain, a wrong verdict can be appealed, and every verdict since the current model set (all NEAR requests, Base 11 and later, Arbitrum 1) can be re-checked by anyone with two CLI commands.
You need near (near-cli-rs), curl and jq. Both calls only read: no wallet, no gas.
curl -s 'https://psephex.xyz/api/requests/near/1/verify' | jq '.data.near.args' > verify-near-1.json
near contract call-function as-read-only oracle.psephex.testnet verify_consensus file-args verify-near-1.json network-config testnet nowOutput of that call on 14 November 2026:
{
"answer": "YES",
"ok": true,
"reason": "",
"required": 2,
"votes": [
{ "answer": "YES", "model": "Qwen/Qwen3.6-35B-A3B-FP8" },
{ "answer": "YES", "model": "deepseek-ai/DeepSeek-V4.1-Flash-1017" },
{ "answer": "YES", "model": "phala/gemma-4-26b-a4b-uncensored" }
]
}The contract checked each model's signature against the keys registered on NEAR; required is the number of matching answers it needs, and all three said YES. The API only supplied the arguments: check that the question is the one NEAR stored, or change one character and watch the same call refuse it in Try to forge a verdict.
Two LLM agents settle a real x402 payment and take the dispute to court on their own. Watch the 2:53 demo.
| Ask from | NEAR testnet (pay in NEAR), Base Sepolia 84532 and Arbitrum Sepolia 421614 (pay in ETH). Testnet only. |
| Models | DeepSeek V4.1 Flash and Qwen3.6 35B on NEAR AI Cloud, Gemma 4 26B on Phala. All three must return a signed answer; two of the three must agree. |
| Live | psephex.xyz (landing), psephex.xyz/app (dashboard), psephex.xyz/api/health (read-only API), docs.psephex.xyz (documentation). Testnet only. |
| Answer time | 17.5 to 21.1 s from the relayer seeing a question to the answer on Base (requests 10 to 13); about 9 s for a NEAR question (8.1 to 9.4 s, NEAR requests 1 to 6) |
| Cost per question | NEAR: 0.01 NEAR fee plus 0.003 to 0.023 NEAR storage, by question length. Base: 0.0001 ETH fee, about 16 Tgas on NEAR, 67k to 107k gas on Base with a dispute callback |
| Forgeries refused | 12 of 12 on the live contracts, one of them copy-paste: try to forge a verdict |
| Tests | NEAR oracle 161, NEAR court 47, NEAR dispute 19, Base 79, relayer and API 241, web 163, MCP 23 |
| Who it is for | Start here | |
|---|---|---|
| An agent on the court | Claude, Cursor or any MCP client that buys or sells work | claude mcp add psephex -- npx -y @unitynodes/psephex-mcp, then the agent quickstart |
| A NEAR contract | Any contract that needs a yes or no it can trust | ask with ask_deposit(question) attached and on_answer(request_id, answer), see Ask from a NEAR contract |
| A Base or Arbitrum contract | Solidity apps that want the same verdict | ask on AiOracle with the fee and onAnswer, see Ask from Base or Arbitrum |
The API and the relayer only carry signed answers; the NEAR contract decides whether they count. On 13 November 2026 we took the real answers to NEAR request 1 (YES, 3 of 3) and Base request 11, forged them in every way we could think of, and sent them to the live contracts. Every attempt was refused:
| Forgery | Refused by | Reason |
|---|---|---|
| Change one model's answer from YES to NO | NEAR oracle | invalid signature |
| Change two answers to flip the majority | NEAR oracle | invalid signature |
| Swap two models' signatures | NEAR oracle | invalid signature |
| Keep the answers, make the question stricter | NEAR oracle | invalid signature |
| Reuse the answers for another request | NEAR oracle | invalid signature |
| Reuse the answers for another chain | NEAR oracle | invalid signature |
| Leave out one model's answer | NEAR oracle | answers must cover every registered model exactly once |
| Count one model twice | NEAR oracle | answers must cover every registered model exactly once |
| Put in a model not registered on NEAR | NEAR oracle | answers must cover every registered model exactly once |
| Deliver an answer to Base from any address but the MPC one | AiOracle on Base | OnlyOracle |
| Deliver a second answer to Base request 11 from the MPC address | AiOracle on Base | AlreadyFulfilled(11) |
Call the Base escrow's onAnswer directly |
Dispute on Base | OnlyOracle |
Try the first one yourself. These are read-only calls: no wallet, no gas.
curl -s 'https://psephex.xyz/api/requests/near/1/verify' | jq '.data.near.args' > real.json
jq '.answers[1].response_body |= sub("\"content\":\"YES\""; "\"content\":\"NO\"")' real.json > forged.json
near contract call-function as-read-only oracle.psephex.testnet verify_consensus file-args forged.json network-config testnet nowExpect "ok": false and deepseek-ai/DeepSeek-V4.1-Flash-1017: invalid signature. Run the same command on real.json and it returns "ok": true, "answer": "YES".
The same refusals are unit tests that CI runs on every push, green in run 43466924990 (jobs near (contracts/near) and base):
- changed answer, question or request:
tampered_response_fails,different_question_or_request_id_fails,consensus_rejects_any_bad_signature,consensus_rejects_signature_by_other_models_key; - another chain:
answer_signed_for_one_chain_fails_on_another; - missing, doubled or unregistered model:
consensus_requires_every_registered_model_exactly_once,consensus_rejects_unregistered_model; - Base:
test_fulfill_fromNonOracleReverts,test_fulfill_replayReverts,test_dispute_onAnswer_onlyOracleContract.
The forgeries in the table were read-only calls, so they left no transactions. A refusal that did land on chain is in Transactions to look at.
A party cannot steer the court through its own evidence either. The court quotes each side's text as a JSON string after a line telling the models to treat it only as evidence, and a newline inside a text cannot start a forged line (contracts/near-court/src/tests.rs).
Real testnet transactions, read from the chain; each link opens the transaction with its logs.
| What happened | Transaction | What it shows |
|---|---|---|
| A verdict by 2 of 3 | 7446TGox…2jh |
fulfill_on_near for NEAR request 4: Gemma YES, DeepSeek UNKNOWN, Qwen3.6 YES, verdict YES. The same transaction calls the court, which logs decided YES for case 1. |
| An appeal | F7WjAYxd…6ws |
The seller agent appeals case 1 to the arbiter psephex.testnet with a 0.02 NEAR bond. |
| The court pays after a silent arbiter | 38eqcf6Z…imW |
The arbiter did not rule within its window; finalize pays the buyer by the verdict (verdict_after_silent_arbiter) and returns the bond to the appellant. |
| The court refuses an early payout | DjneqyGN…L2YXv |
The seller agent calls finalize on case 4 while the appeal window is open; the contract panics with the appeal window is still open. |
| Two LLM agents settle | HNrbS7bB…ofg |
Case 4, NEAR request 6, YES 3 of 3: finalize pays the stake to the buyer agent (by: verdict). |
| A verdict delivered to Base by MPC | 0x427d1002…7a6d |
Base request 11, sent from the MPC-derived address 0x3A91…e35F. |
| What | Where |
|---|---|
| NEAR oracle contract | oracle.psephex.testnet (v4, wasm sha256 0f390e19…, no access keys): ask, fulfill_on_near, verify_consensus, Chain Signatures for EVM, owner changes only through propose with a 24-hour delay |
| NEAR court (agent deals, both sides, appeal) | psephex-court.testnet: owner and arbiter psephex.testnet (key offline) |
| NEAR dispute v1 (one-sided escrow example) | dispute.psephex.testnet: stake in NEAR, verdict through on_answer |
| AiOracle | Base Sepolia 0x792bCa54672763Af3B1FaA1Fb62d3Cb2fCff6111 |
| Dispute (escrow example) | Base Sepolia 0xCa744C595A6C2EE470257D2B873aEd2b1a78E092 |
| AiOracle and Dispute on Arbitrum | Arbitrum Sepolia, the same addresses: 0x792b…6111, 0xCa74…E092 |
Oracle address (NEAR MPC, path base-1) |
0x3A915e664Bc3c87954b9C1CaD2146B44A8a2e35F |
| NEAR owner and relayer | psephex.testnet, relayer.psephex.testnet (one function-call key per relayer process: fulfill_on_evm, fulfill_on_near) |
NEAR: fee 0.01 NEAR plus storage per question (ask_deposit(question) gives the exact amount, the rest is refunded), dispute minimum stake 0.01 NEAR. Base: fee 0.0001 ETH, dispute minimum stake 0.001 ETH. Questions up to 2000 bytes, dispute timeout 300 s. ABI: contracts/base/ABI.md.
The oracle address 0x3A91…e35F is the same on every EVM chain: one NEAR account and one MPC path. Arbitrum dispute 1 was answered YES by the three models and delivered by it.
Note
You need near (near-cli-rs), cast (Foundry) and jq. The API only hands over the arguments; every check below runs on the NEAR contract or the EVM chain.
A question asked from NEAR. Dispute 1 on dispute.psephex.testnet asked whether a logo delivered as a 1024x1024 PNG met a contract for at least 512x512; NEAR request 1 holds the verdict.
near contract call-function as-read-only oracle.psephex.testnet near_request json-args '{"request_id":1}' network-config testnet nowExpect "answer": "YES" and three votes. The verdict lives in the NEAR contract state.
curl -s 'https://psephex.xyz/api/requests/near/1/verify' | jq '.data.near.args' > verify-near-1.json
near contract call-function as-read-only oracle.psephex.testnet verify_consensus file-args verify-near-1.json network-config testnet nowExpect "ok": true and "answer": "YES": the NEAR contract rebuilt the request for near:testnet, checked each model's signature against the keys registered on NEAR, and found two of three matching.
The signatures only mean something for the question NEAR stored, so check that the API handed over that question:
diff <(jq -r .question verify-near-1.json) <(near contract call-function as-read-only oracle.psephex.testnet near_request json-args '{"request_id":1}' network-config testnet now | jq -r .question) && echo same questionA question asked from Base. Request 11 on Base asked the same question.
curl -s 'https://psephex.xyz/api/requests/base/11/verify' | jq '.data.near.args' > verify-base-11.json
near contract call-function as-read-only oracle.psephex.testnet verify_consensus file-args verify-base-11.json network-config testnet nowExpect "ok": true and "answer": "YES" for chain eip155:84532.
jq -j .question verify-base-11.json | cast keccak
cast call 0x792bCa54672763Af3B1FaA1Fb62d3Cb2fCff6111 'getRequest(uint256)((address,bytes32,bool))' 11 --rpc-url https://sepolia.base.orgExpect the same hash 0xa50bcbbe…efe68 from both: the question the models answered is the one asked on Base, and fulfilled is true.
cast tx 0x427d1002f44249de44cd038d48a99d0236a08554192ada74b5c1218093107a6d from --rpc-url https://sepolia.base.orgExpect 0x3A915e664Bc3c87954b9C1CaD2146B44A8a2e35F: the answer was delivered by the MPC-derived address, which no person holds a key for.
The API only hands over the arguments; the check runs on the NEAR contract. Change one character of a response_body in either JSON file and verify_consensus returns "ok": false with invalid signature; the full list of forgeries we tried is in Try to forge a verdict.
The owner's hands are tied. The oracle account has no keys, so code changes only through an announced upgrade:
near account list-keys oracle.psephex.testnet network-config testnet now
near contract call-function as-read-only oracle.psephex.testnet proposals json-args {} network-config testnet now
near contract call-function as-read-only oracle.psephex.testnet owner_delay_seconds json-args {} network-config testnet nowExpect no keys, [] or the open proposals with the time each may run (ready_at_ns), and "86400". Every proposal also logs an owner_change_proposed event.
A case runs on testnet between two agent accounts, psephex-agent-buyer.testnet and psephex-agent-seller.testnet:
- the buyer agent opens a case on
psephex-court.testnet("the 100-row dataset I prepaid arrived with 60 rows") with its evidence and a stake; - the seller agent answers with its own evidence ("only 60 plants matched the filter");
- the court writes the oracle question from both texts (
question_for), three TEE models answer, NEAR checks two of three; - the appeal window runs; without an appeal anyone calls
finalizeand the stake goes by the verdict.
Agents can run a case themselves through the MCP server in mcp/ (13 tools: open and answer cases, check a NEAR or x402 payment, verify a verdict, look up an agent's record). It is published on npm as @unitynodes/psephex-mcp and listed in the MCP Registry as io.github.UnityNodes/psephex; in Claude Code:
claude mcp add psephex -- npx -y @unitynodes/psephex-mcpWithout NEAR_ACCOUNT_ID and NEAR_PRIVATE_KEY it only reads; the stake caps and the other settings are in mcp/README.md. mcp/examples/x402/ settles an x402 payment in wNEAR on NEAR testnet without a facilitator. mcp/examples/llm-agents/ is an LLM agent on NEAR AI Cloud that drives the MCP server: in case 4 one such agent checked that payment and opened the case, a second one answered it, and the first verified the verdict, with no human in the loop: YES, 3 of 3, stake to the buyer.
The dashboard at psephex.xyz/app (source in web/) is what a judge with a fresh wallet used in our end-to-end test:
- Open psephex.xyz/app and choose "Open a dispute". NEAR testnet is the default and opens a court case: connect a NEAR testnet wallet (MyNearWallet, Meteor, HOT, HERE, Intear, NEAR Mobile, or an extension such as Sender, OKX, Bitget, Nightly, Coin98, Math or WELLDONE; test NEAR from the faucet). The form shows the stake, the oracle reserve and the storage before you sign.
- Pick the example "Dataset short by 40 rows", enter the seller's account and open the case. The seller answers from its own wallet with "Send the response" within 120 s; if it stays silent, anyone sends the case on after the window. About 9 s later the page shows three signed ballots and the NEAR transaction that checked two of three.
- After the 120 s appeal window, "Finalize and pay out" sends the stake by the verdict: YES or UNKNOWN to the claimant, NO to the seller. Either party can appeal to the arbiter before that.
- For Base Sepolia or Arbitrum Sepolia, switch the chain and connect a browser wallet. That form opens a one-sided escrow dispute and needs 0.0011 ETH plus gas from the Base faucets. "Logo delivered as specified" comes back YES in about 20 s through an MPC-signed transaction; "A matter of taste" comes back UNKNOWN and the page offers the refund button.
- On any answered request, "Check it yourself" lists the commands above for that request.
The escrow examples were run ten times on every model before they went on the form.
The five steps from a question to a payout, with the exact checks at each one
- The question is recorded. From NEAR, a person or contract calls
oracle.psephex.testnet.ask(question, callback)with a NEAR deposit; the contract stores the question and emitsasked. From Base, a contract callsAiOracle.ask(question)with the fee; Base stores the question hash and emitsAsked. - Three models answer in TEEs. The relayer asks the NEAR contract to build the exact request (temperature 0, fixed seed, the request id and the source inside the prompt: the NEAR contract account, or the AiOracle address and EVM chain id) and sends those bytes to each model. NEAR AI models sign
model:sha256(request):sha256(response)with their own key; on Phala the attested Dstack gateway signssha256(request):sha256(response). - NEAR checks two of three.
fulfill_on_nearorfulfill_on_evmrebuilds the request, needs a signed answer from each of the three registered models, verifies every signature against the keys registered on NEAR and needs two matching answers. For a NEAR question it takes the question from its own state, so the relayer cannot change it. - NEAR keeps the verdict, or MPC signs it for an EVM chain. A NEAR question ends here: the verdict and votes are stored in the contract and
on_answer(request_id, answer)is called on the asker when it asked for a callback;dispute.psephex.testnetpays out from that call. For Base the contract builds the EIP-1559 transaction and asksv1.signer-prod.testnetto sign it; the relayer only carries signed bytes. - Base pays out.
AiOracle.fulfillaccepts the answer only from the MPC address and only for the matching request id and question hash, then calls the asking contract. Both dispute contracts pay the claimant on YES, the counterparty on NO, and allow a refund on UNKNOWN or after the timeout.
The relayer (relayer/) is a crash-safe state machine over SQLite: killed with kill -9 between steps it resumes without signing twice. The read-only API (relayer/src/api/) runs as a separate process with no keys.
- Each answer was signed inside a TEE by a key registered on NEAR and attested with a fresh nonce: the model's own key on NEAR AI, the gateway's key on Phala.
- At least two of the three signed answers agree, checked by the NEAR contract, not by our server.
- The models saw the request the NEAR contract built from the question asked on NEAR or on Base.
- Only the MPC-derived address can deliver the answer, and only for the matching id and question.
- Answers repeat in practice: 80 of 80 repeats matched in the first check, 90 of 90 for the dashboard examples on NEAR AI and 30 of 30 on Phala.
- The court's code cannot change:
psephex-court.testnethas no access keys since its deploy. - The oracle's rules cannot change under a case. Since 10 November
oracle.psephex.testnethas no access keys, and a new model key, EVM target, reset of a settled request, higher gas cap or new code is announced on chain withproposeand runs only 24 hours later, within a seven-day window. New code runs only if its sha256 was announced.
- That the answer is right. In Base request 2 all three models said 9 is a prime number, and the oracle delivered that.
- That asking again is impossible. Temperature 0 and the seed make repeats match in practice, not cryptographically.
- Fully independent operators. Two models run on NEAR AI and one on Phala; on Phala one attested gateway signs for the model it routes to.
- Knowledge of fresh events. The evidence has to be in the question.
- A verdict while a provider is down. "Two of three" counts matching answers, not answering models:
verify_consensus(contracts/near/src/lib.rs) needs a validly signed answer from each of the three registered models, and counts a signed answer it cannot parse as UNKNOWN. If NEAR AI Cloud (two models) or Phala (one) is down, no verdict can be recorded until it is back or the owner replaces that model throughpropose, which takes 24 hours. A court case then waits, and after its answer timeout (600 s on testnet) anyone can callrefund, which returns the stake to the claimant. A Base or Arbitrum dispute allows a refund after its 300 s timeout. - The same delay on Base and Arbitrum. AiOracle on both has the owner
0x06280879748d27F682b14830B1AfEf0d7AF223E2, a test key from the first deploy on 8 November. An owner can replace the delivery address (setOracle) or the fee at once, outside the NEAR delay. The author no longer holds that key, which no chain can show. - Immutable oracle code. The owner
psephex.testnet(key held offline by the author) can still replace the models or the code in the open, a day after announcing it, and the oracle code decides what the MPC network signs for Base and Arbitrum. The server only has function-call keys ofrelayer.psephex.testnetthat can submit answers.dispute.psephex.testnet, the v1 example, still has a full-access key. - Fixed court parameters. The court owner
psephex.testnetcan change the stake minimum, the appeal bond and the response, appeal and arbitration windows with immediate effect, and a case reads them when it enters each stage. The court has no keys, so its code cannot change. - A fixed model set. Qwen3.8 27B answered Base requests 1 to 10 and was replaced by Gemma on 2026-11-09;
verify_consensuschecks the current set, so those requests are verified by their NEAR and Base transactions.
Intel's DCAP signature chain on the TDX quotes was not verified by us; we checked that each quote's report data holds the signing key and our nonce.
Every test suite, the wasm rebuild and what each service needs
From the repository root:
The deployed oracle wasm (sha256 0f390e19…) rebuilds from this tree with cargo-near 0.22.0 and rustc 1.96.0:
(cd contracts/near && cargo near build non-reproducible-wasm --locked && sha256sum target/near/near_oracle.wasm)(cd contracts/near && cargo test --locked)(cd contracts/near-dispute && cargo test --locked)(cd contracts/near-court && cargo test --locked)(cd contracts/base && forge test)(cd relayer && npm ci && npm test)(cd web && npm ci && npm test)(cd mcp && npm ci && npm test)The relayer needs a NEAR function-call key, a NEAR AI key and a Phala (RedPill) key; the API needs none. Their variables are listed in .env.example and read in relayer/src/config.ts. The relayer runs with node relayer/dist/main.js, the API with node relayer/dist/api/main.js; the dashboard build needs VITE_API_URL and the fonts from scripts/fetch-fonts.sh.
| Folder | What it is |
|---|---|
contracts/near |
NEAR oracle contract: 2-of-3 signature check, Chain Signatures for EVM, owner timelock (Rust, near-sdk) |
contracts/near-court |
NEAR court for agent deals: both sides' evidence, appeal, arbiter |
contracts/near-dispute |
NEAR one-sided escrow example (v1) |
contracts/base |
AiOracle, Dispute and the YesNoClient example (Solidity, Foundry) |
relayer |
Relayer state machine and the read-only API (TypeScript) |
web |
Landing and dashboard (Vite, React, wagmi) |
mcp |
MCP server for agents, with the x402 and LLM agent examples |
docs-site |
Documentation at docs.psephex.xyz (VitePress) |
The earliest work on Psephex is the prototype tested on 07 and 08 November 2026, moved into this repository on 08 November (commit a1e4cef). Everything else was built from 08 to 11 November; the git history is the record.
Libraries: near-sdk 5.30.1 and omni-transaction 0.5.0 (NEAR contract); forge-std (Base tests); near-api-js 7.4.0, viem 2.57.16, better-sqlite3 13.0.3, pino 10.4.0, Fastify 5.12.8 and @fastify/rate-limit 11.2.1 (relayer and API); React 19.3.1, wagmi 3.7.9, @near-wallet-selector 10.1.4 (MyNearWallet, Meteor, HOT, HERE, Intear, NEAR Mobile, Bitget, Nightly, Sender, OKX, Coin98, Math, WELLDONE), TanStack Query 5.104.5, react-router 8.5.0, zod 4.6.7 and Tailwind 4.3.3 (web); @modelcontextprotocol/sdk 1.32.2 (MCP server); VitePress 1.6.4 (docs). Models: NEAR AI Cloud and Phala Confidential AI through RedPill.
AI assistance: the code, tests and documentation in this repository were written with Claude Code.
Agent Economy, AI Security & Defense and Open Innovation: an open primitive on NEAR that also serves EVM chains, AI models acting as verifiable judges for contracts, and a design whose trust rests on TEE attestation, a 2-of-3 rule enforced on chain and MPC signing instead of a server key.
NEARpedia (repository): live NEAR knowledge for AI agents, an MCP server and API that tells a coding agent when the NEAR code it is about to write is stale.
MIT, see LICENSE.