Skip to content
ArhamKhan117Public

About

A private OTC desk on NEAR, run by AI agents: shielded balances, sealed requests matched inside a TEE, both legs settled in one private call, and proofs shown to one named reader.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Hushd: private OTC on NEAR, run by agents

Live at hushd.net Network: NEAR testnet Contracts: source verified on NearBlocks @hushd/sdk on npm @hushd/mcp on npm Latest release License: MIT

Try it · How a deal works · Only on NEAR · Contracts · Privacy and security · Agents · Run it · Tests


Private OTC, run by agents

Trade size on NEAR without showing your hand. On a public chain, asking for a quote tells the market what you want before you get it. Hushd seals the request instead: maker agents quote blind, a TEE enclave picks the best price inside your limit, and both legs settle privately in one call.

The makers are autonomous agents that quote and settle the deals they win, and any AI agent can trade, pay over private x402 and prove through MCP, acting on NEAR through a policy wallet. Afterwards the trader, a person or an agent, can prove exactly one fact, such as "I paid this deal" or "I hold at least 10,000 USDC", to one named NEAR account until a date they choose.

Live on NEAR testnet with test tokens, and mainnet-ready: the same code runs on mainnet after a proving-key ceremony, an external audit and a deploy (MAINNET.md).

Demo video (four minutes): on X.

Check it in five minutes, no account

  1. Every claim, live: clone this repository, then run pnpm install && pnpm verify (Node 22, no keys, about 30 seconds). You see one PASS or FAIL per claim in this README, checked against the testnet deployment, ending in "15 of 15 claims hold".

  2. A proof for one reader: open hushd.net/verify, paste deployments/judge-proof-payment.txt and give judge.testnet as the reader. You see it hold, checked in your browser and again by the pool contract; give any other account and it is refused.

  3. The desk from an agent: claude mcp add --transport http hushd-read https://hushd.net/mcp, then ask it for the makers or deal 130. You see live data from the desk and the pool, with no keys and no sign-up.

  4. A hedge on Hyperliquid:

    curl -s https://api.hyperliquid-testnet.xyz/info -H 'content-type: application/json' -d '{"type":"orderStatus","user":"0x2b43bd1969ac858dd04b1183886228cc9209bbfc","oid":65293516022}'

    You see "status":"filled" for deal 130's 598.3 NEAR order, on the account of Ledger, the maker that won it (more).

At a glance

Area In short
What A private OTC desk on NEAR, run by agents: sealed requests, matched inside a TEE, both legs settled privately in one call
Live App at hushd.net, API at api.hushd.net, MCP server at https://hushd.net/mcp, contracts on NEAR testnet
Contracts pool, desk, board and three test tokens: reproducible builds, source-verified on NearBlocks
Privacy Notes in a shielded pool, Groth16 proofs checked on chain with alt_bn128, and proofs of one fact for one named reader until an expiry
Matching An OutLayer TEE enclave, pinned by the desk to one build behind a 24-hour timelock; deal amounts stay out of the public terms hash
Agents Three maker agents acting through OutLayer policy wallets; an MCP server with 22 tools and spending limits (npx -y @hushd/mcp), plus a hosted read-only one live at hushd.net/mcp; private x402; NEAR Intents trades
Packages @hushd/sdk, @hushd/protocol and @hushd/mcp on npm
Check it pnpm verify checks every claim in this README against the live deployment and prints PASS or FAIL

Try it

  • The desk: hushd.net/app. Sign in with a NEAR wallet or a passkey, take test tokens from the faucet, add them privately, then ask the desk in your own words or with the form.
  • The trading screen: hushd.net/app/trade. Live Hyperliquid prices for each pair the desk trades, a ticket that seals the request, the makers and their bonds, a payoff chart of what you hold, and your requests, deals, hedge legs and receipts below.
  • Check a proof: hushd.net/verify. Two real ones made for judge.testnet are in deployments/ (a payment that settled desk deal #2, and funds held).
  • Agents, live now: the hosted MCP server at https://hushd.net/mcp answers any MCP client, with no keys and no sign-up: claude mcp add --transport http hushd-read https://hushd.net/mcp. Its five read tools read the pool, the desk, the makers and deals, and check proofs. For all 22 tools (a private balance, payments, trades and proofs, inside spending limits), run npx -y @hushd/mcp with the agent's own seed (see Agents).
  • The live claims, checked: pnpm verify checks the deployment against this README (contracts, their code and the commit each was built from, the enclave key, bonded makers, settled deals, the services and the indexer, the agents' policy wallets, a two-agent trade's signatures, keys and nonces checked by intents.near's simulation on mainnet, the intake attestation and a signed intake answer, private x402, the hosted MCP and an on-chain proof check) and prints PASS or FAIL for each.

What you can do

  • Hold a private balance. Tokens become notes in a shielded pool. Only your key spends them, and nobody can see what you hold.
  • Send, receive and cash out privately. A relayer sends every proven action from its own account, so your NEAR account never appears next to your payments. Payment request links fill in the amount for the payer.
  • Pay anyone as a link. The payment waits in a one-time note, and whoever opens the link claims it into their own private balance with a passkey or a NEAR wallet, with no gas and no seed phrase (the Send page, or hushd_pay_link for agents). An unclaimed link can be taken back.
  • Ask for a price without showing your hand. Your request, including the least you accept, is sealed to the matcher enclave. Makers see the pair, the side and the size, never your limit.
  • Trade three packages. Spot settles atomically in the pool. Spot plus hedge and cash and carry are experimental: you receive the same spot leg, and the maker commits, with its bond at stake, to place a Hyperliquid testnet hedge order signed by NEAR Chain Signatures from a per-deal address that trades for the maker's own account. If the order misses, the bond is paid to you privately. The hedge is the maker's position, not yours. A bond is at least the desk's 1,000 USDC minimum, so hedged packages suit trades from about 10,000 USDC.
  • Describe the trade in plain words. A NEAR AI Cloud model inside a TEE drafts the request. Your words are encrypted to the model's attested key in the browser, and the answer's TEE signature is checked in the browser too. You confirm every number.
  • Prove one fact to one reader. An exact payment, a payment of at least an amount, funds held above a threshold, or your total desk volume. Each proof names its reader and expires, and the pool contract checks it again on chain.
  • Let agents do all of it through MCP, inside per-payment and per-day limits, including paying x402 resources privately.
  • Give each agent a policy wallet. The agent's NEAR key lives in OutLayer's TEE, which signs only calls to Hushd's contracts within the owner's NEAR, rate and hour caps. The owner can freeze it with one transaction, and a frozen agent stops spending privately too. The desk's own makers work this way.
  • Trade on NEAR Intents. Two agents can settle a trade on intents.near with one transaction: each signs its side as a token_diff, and the verifier executes both or neither. The trade is tested on a local node running intents.near's code and is ready to run on mainnet; that run waits for the owner's go-ahead. 1Click quotes from 39 chains (NEAR included) price the makers and preview deposits from, and cash-outs to, other chains.

How a deal works

How one deal works: the trader seals a request to the enclave, makers send sealed and signed quotes, the enclave signs the best match inside the limit, then both legs settle in one pool call with a receipt and, for hedged packages, a Chain Signatures hedge

  1. The trader builds a package request and seals it to the enclave's key. Only its sha256 goes on chain (desk.open_rfq).
  2. Each registered maker gets an ask sealed to its own key: pair, side and size only.
  3. Makers answer with quotes sealed to the enclave. Each quote is signed by the maker's quote key over the terms hash, bond and expiry; the desk checks that signature on chain.
  4. When the window closes, the enclave opens everything, picks the best quote inside the trader's limit and signs the match. The desk accepts a match only from OutLayer's callback or under the enclave key.
  5. Trader and maker swap the openings of the notes they make for each other in a sealed deal room (the trader under a key made for that deal alone; the API deletes the room once the deal closes, and after a day at most), check them, and each proves a leg bound to the deal and all four outputs.
  6. desk.settle calls pool.settle_swap: both legs or neither. The desk records a receipt: settled, recovered, failed or unresolved, with evidence.
  7. For hedged packages (experimental), the keeper has the MPC sign the maker's Hyperliquid order from the path hushd/hedge/<deal id>. The maker's Hyperliquid account approves that address as its agent, so the order trades for the maker, not the trader. The keeper reports the fill or the miss; if the hedge misses its deadline, the maker's bond is paid to the trader as a private note.

Only on NEAR

What Where you see it
Groth16 proofs verified on chain with NEAR's alt_bn128 host functions (a proof check is about 36 Tgas; a private send's pool call about 90, a two-leg settlement about 125) Every private send, cash out and settlement; /verify asks the pool to check a proof again
Chain Signatures sign each deal's Hyperliquid order from its own derivation path A deal page's hedge row: deal 130, whose order filled on the winning maker's own Hyperliquid testnet account (check it yourself)
OutLayer runs the matcher in a TEE, with on-chain yield and resume for the desk's enclave key Makers page, "The matcher"
NEAR AI Cloud verifiable private inference, attestation checked with @nearai/inference-sdk Desk, "Describe it"
Named accounts as proof readers: a proof is for auditor.testnet, not for a key Prove page, "Who may read it"
Passkeys that derive an implicit account, opened by the relayer with 0.2 testnet NEAR for its own gas Sign in with a passkey
Gas keys give the relayer parallel nonce lanes; it also relays NEP-366 meta transactions for allowlisted calls The Trade screen's status bar, "Relayer" (its lanes)
NEP-141 ft_transfer_call deposits straight into the pool Balance, "Add privately"
OutLayer agent custody: each agent's NEAR account is a policy wallet whose key stays in a TEE; the owner stores the policy on chain and can freeze it Agents page, "Policy wallets"; Makers page
NEAR Intents direct trades: complementary token_diff intents signed by two agents, one execute_intents, simulated first with simulate_intents (tested on a local node running intents.near's code) Transparency, "On NEAR Intents (mainnet)", which lists the mainnet trade's transactions once it runs
1Click quotes across 39 chains (NEAR included), as the makers' second price and for deposits from and cash-outs to other chains Balance, Add and Cash out, "another chain"
NEP-297 events read from FastNEAR's free transactions API by the indexer (or its neardata block stream) A deal page's "On chain" list

Check a hedge yourself

Hyperliquid's public API shows each hedge order on the account it traded for, with no login. Ledger won deal 130, and its order (oid 65293516022) filled 598.3 NEAR on Ledger's own Hyperliquid testnet account:

curl -s https://api.hyperliquid-testnet.xyz/info -H 'content-type: application/json' -d '{"type":"orderStatus","user":"0x2b43bd1969ac858dd04b1183886228cc9209bbfc","oid":65293516022}'

The same query for Steady's account (0xcfd5ba482f2be11812ded5fb5a26318eea503a3b) or Weather's (0x36d1429bd060eeb24cb28a07b724ecbdaaf81be7) answers unknownOid.

Deal 122, the hedge in the demo video, filled too (oid 65225181835, 562.7 NEAR), but on Steady's account, although Ledger won that deal. A readiness check had approved deal 122's address as Steady's agent on Hyperliquid before the deal existed, so Hyperliquid credited the order to Steady. Commit 60558ea made the check approve a throwaway address instead, and deal 130 is the first hedge after it. Check deal 122 with "user":"0xcfd5ba482f2be11812ded5fb5a26318eea503a3b","oid":65225181835. The records are deployments/testnet-hedge.json (deal 130) and deployments/testnet-hedge-122.json.

Contracts

Contract Account Does Source
Pool pool.hushd.testnet Notes, nullifiers, a depth-20 Poseidon tree, deposit limits behind a timelock, transact, settle_swap, verify_disclosure Verified on NearBlocks
Desk desk.hushd.testnet Makers and bonds, RFQ commitments, enclave matches, settlement, receipts, hedges, slashing Verified on NearBlocks
Board board.hushd.testnet Sealed note posts, so a seed alone recovers a wallet Verified on NearBlocks
Tokens usdc, wnear, btc.hushd.testnet Test NEP-141 tokens with a faucet Verified on NearBlocks: usdc, wnear; btc runs the same code (same code hash)

Every contract on testnet is a reproducible build, and its source is verified three ways:

  • On NearBlocks: Verify and Publish rebuilt each contract from this repository through SourceScan's verifier, and each one's Contract Code tab shows "Contract Source Code Verified" with the source it was built from (btc shares usdc's and wnear's code hash, so it was not submitted separately).
  • By you: each contract names the commit and the pinned sourcescan/cargo-near Docker image it was built from (NEP-330 contract_source_metadata), so near contract verify deployed-at pool.hushd.testnet network-config testnet now rebuilds it byte for byte and compares the hash.
  • By pnpm verify: it checks that each account runs the code hash recorded in deployments/testnet.json, names a commit of this repository and a pinned image, and matches your own reproducible build.

Privacy and security model

What stays private: who holds what, who paid whom, the amounts inside the pool, the parties and amounts of a desk deal, and the trader's limit. The winning maker pays the trader at a one-time address made for that deal, so it cannot link two of its deals to one trader by address (pair, size and timing can still hint at it).

What is public: deposits into the pool and cash outs out of it, with their amounts; that a deal exists, its settlement class, its maker and its outcome; a hedged deal's bond (only in fixed steps of the desk minimum, so it does not give the size away) and its hedge order on Hyperliquid (which does). On Hyperliquid every hedge a maker places shows on that maker's account, whichever per-deal address signed it. Timing can link a deposit to a later action, so wait and use round amounts when that matters.

Sanctions screening covers public addresses only: the NEAR account a deposit comes from, the account a cash out pays, and an address on another chain used through NEAR Intents. They are checked against a dated snapshot of the digital currency addresses on OFAC's SDN list (packages/sdk/src/screening.ts), in the app before you sign, at the API (POST /v1/screen) and again by the relayer before it sends a cash out. A listed address sees one neutral line. Notes, amounts and hushd1… addresses are never screened.

Who you trust, and for what:

Party What you trust it for
The relayer Run by Hushd. It sends what you proved. It dry-runs every proof and can refuse to send one, but it cannot change a recipient, an amount or a fee, because the proof binds them.
The API Run by Hushd. It stores the sealed requests, quotes and deal-room messages and passes them on. It cannot open them, but it sees IP addresses, timing and deal-room traffic, and it can refuse, delay or drop a message.
The matcher client Run by Hushd. It builds each batch for the enclave from the quotes in the API's database (services/src/matcher.ts). It cannot read them or forge a match, but it could leave a quote out, and the enclave could not tell.
The keeper Run by Hushd. It submits each hedge order and alone reports whether it filled; the desk releases or slashes the maker's bond on that report.
The matcher enclave It sees requests and quotes in the clear inside the TEE. You trust OutLayer's attestation that it runs this repo's matcher/ code: cd matcher && cargo build --release --locked --target wasm32-wasip2 rebuilds the build the desk pins, sha256 95cba282e110f209a8a2a9722dfa8b1e9be777a45ab5a9fcaf78a74a4bbcd876 (checked with Rust 1.98.1).
The maker It sees the pair, side and size of your ask and, after a match, the deal terms. It also has a last look: the trader proves its leg first and the maker submits both, so it can wait out the settlement window and settle only if the price still suits it. That costs it no bond on a spot deal, but the lapse is public and requests skip a maker that let more than 25% of its recent deals lapse.
NEAR AI Cloud It decrypts your words inside an attested TEE. The Hushd API only forwards ciphertext.

Status: NEAR testnet with test tokens and development proving keys, and mainnet-ready on the same code path; going live is a proving-key ceremony, an external audit and a deploy (MAINNET.md). The contracts have had an internal review and automated scans, with every finding fixed or accepted with its reason (SECURITY.md).

Agents

Live, hosted, read-only: https://hushd.net/mcp (Streamable HTTP, stateless, no keys). Connect it with nothing installed:

claude mcp add --transport http hushd-read https://hushd.net/mcp
curl https://hushd.net/mcp          # what it is and its tools, as JSON

It serves hushd_status, hushd_makers, hushd_desk_deals, hushd_deal and hushd_verify_proof against the live testnet contracts, and pnpm verify calls it on every run.

The full server, with the agent's own seed and spending limits, is @hushd/mcp on npm, with no clone:

npx -y @hushd/mcp init              # a new agent seed in ~/.hushd/seed (mode 600)
claude mcp add hushd \
  -e HUSHD_LIMIT_PER_PAYMENT="USDC=100,wNEAR=50" \
  -e HUSHD_LIMIT_PER_DAY="USDC=500,wNEAR=250" \
  -- npx -y @hushd/mcp

Or from this repository:

pnpm install
pnpm mcp init                       # a new agent seed in ~/.hushd/seed (mode 600)
claude mcp add hushd \
  -e HUSHD_LIMIT_PER_PAYMENT="USDC=100,wNEAR=50" \
  -e HUSHD_LIMIT_PER_DAY="USDC=500,wNEAR=250" \
  -- pnpm --silent --dir "$PWD" mcp
Package What it is
@hushd/mcp The MCP server: a private balance, payments, claim links, private x402, the desk and proofs, inside spending limits
@hushd/sdk The TypeScript SDK the app, the MCP server and the makers use: the private wallet, desk flows, proofs, NEAR Intents and policy wallets
@hushd/protocol Package terms, exact integer math and the canonical bytes makers and the enclave sign
  • 22 tools: balance and address, faucet and shield, send and cash out, claim links (pay, claim, list, take back), hushd_trade, hushd_prove, hushd_pay_x402, limits, hushd_policy, deals and payments, and the read tools.
  • The limits run in the local MCP process beside the seed and are the only guard on the private balance; the relayer does not enforce them. hushd_pay_x402 obeys the payee list and expiry, and hushd_trade requires min_receive.
  • A policy wallet instead of a NEAR key: pnpm --filter @hushd/services policy-wallet create MY_AGENT (or the Agents page) stores the policy from the owner's account, then the agent gets HUSHD_POLICY_WALLET_KEY. The TEE enforces which contracts it may call and the NEAR it may attach; this server adds token limits, HUSHD_LIMITS_EXPIRE and HUSHD_ALLOW_TO (payees), and refuses to spend while the wallet is frozen.
  • Private x402: a resource answers 402 with scheme hushd; the agent pays a private note to the resource's hushd1... address and sends the note's opening sealed to it; the server checks the pool created exactly that note. The reference makers sell indicative quotes this way.
  • NEAR's Agent Market: deploy/agent-market/ holds Hushd's listing, a "price check" agent (services/src/market-agent.ts) that answers a hire with the live NEAR Intents quote, the Hyperliquid mid and the quotes of Hushd's makers, paying each maker over private x402. pnpm --filter @hushd/services exec tsx scripts/market-listing.ts --try "sell 2500 USDC for NEAR" runs one check. The listing is live as hushd on the Agent Market, answered by the market service.
  • An agent skill for coding agents lives at skills/hushd/SKILL.md, and llms.txt maps the site.

Run it

Read-only, no keys, against the public testnet contracts:

pnpm install
pnpm dev                            # http://localhost:3000

The services (relayer, API, indexer, matcher client, makers, keeper, top-up) with Postgres and Caddy:

cp .env.example .env                # fill in the keys you have; without keys the API runs read-only
docker compose -f deploy/docker-compose.yml up -d --build

Deploy your own copy to testnet from one funded account: pnpm --filter @hushd/services deploy:testnet (DRY_RUN=1 prints the plan and the NEAR it needs).

Tests

pnpm --filter @hushd/circuits compile   # once, needs circom 2: the circuit tests read the compiled circuits
pnpm test                           # circuits, protocol, SDK, services, MCP
cd contracts && cargo test -p hushd-pool -p hushd-desk -p hushd-board -p hushd-token   # with real proofs
pnpm verify                         # the live deployment, claim by claim
pnpm security                       # near-scan, cargo audit and deny, Clippy, pnpm audit (see SECURITY.md)
pnpm --filter @hushd/services intents:sandbox   # the NEAR Intents trade on a local node running intents.near's code

The contract sandbox tests run the whole flow on a local nearcore: build the wasm with cargo near build non-reproducible-wasm in each contract and in contracts/sandbox-tests/doubles/*, then cargo test -p sandbox-tests -- --test-threads=1.

Security checks

pnpm security runs every check and writes security/report.md; all of them pass.

Check What it looks at
near-scan 22 NEAR detector classes (the checklist BlockSec's Rustle reports) on the parsed contract source; each of its 71 hits has a written reason, listed in security/near-scan.md
cargo audit, cargo deny RustSec advisories, licenses and crate sources for the contracts and the matcher enclave
Clippy Rust lints, warnings as errors
pnpm audit npm advisories in the production JavaScript dependencies
pnpm verify The contracts on testnet run the recorded code hashes and name the commit and Docker image they were built from; your reproducible build hashes the same
near contract verify Rebuilds a deployed contract from its commit in its pinned image and compares the hash, the check NearBlocks runs

The contract review of 6 November 2026 found one High: anyone could settle a matched deal with empty legs of their own. It is fixed: desk.settle needs both parties' signatures over the deal's four outputs. That finding, the three Medium and six Low, and what changed for each are in SECURITY.md.

Mainnet

Hushd runs on testnet, and every part is built to run on mainnet too: going live is a deploy and environment switches, with no code changes. pnpm --filter @hushd/services mainnet:sandbox runs the mainnet build end to end on a local node holding the real mainnet USDC, wrap.near and nBTC code: a deploy as hushd.near, the services on mainnet settings, and an agent that shields, sends, trades two pairs, cashes out, proves and pays over x402 (17 of 17 checks pass). Going live takes a multi-party proving-key ceremony (circuits/scripts/ceremony.mjs) and an external audit; MAINNET.md has what is ready, how it was tested and the steps to go live.

Repository

What is in the repository: Rust contracts on NEAR, circom circuits and the OutLayer matcher enclave, and the TypeScript SDK, MCP server, services and app

The file tree: contracts (pool, desk, board, token, sandbox tests), circuits, matcher, packages (sdk, protocol, mcp), services, app, deploy, the agent skill and AGENTS.md

Hackathon

Hushd is entered in the Privacy, DeFi, Agent Economy and AI Security tracks. For the Agent Economy track, what runs is a market of independent agents: three automated makers, each with its own pricing formula (a fixed, a volatility or an inventory spread on Hyperliquid mids), bond, quote key and policy wallet, compete in every sealed auction and settle their own legs, and any agent can join as a trader through MCP and pay for quotes over private x402. No language model sets a price; the one model call in Hushd is the NEAR AI intake, which drafts a request from a person's words. For AI Security: an agent need never hold its NEAR key. It can act through an OutLayer policy wallet, whose TEE signs only calls to Hushd's contracts within caps the owner sets on chain, and the owner can freeze it in one transaction. The MCP server adds per-payment and per-day spending limits per token (packages/mcp/src/limits.ts), and the browser checks the intake model's TEE attestation and signature before it trusts a draft.

License

MIT, see LICENSE.

About

A private OTC desk on NEAR, run by AI agents: shielded balances, sealed requests matched inside a TEE, both legs settled in one private call, and proofs shown to one named reader.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages