Rulings live on HCS topic 0.0.11727107 · testnet · limits
NAY/SAYER

Documentation

How it works

Naysayer rules on one question: should this agent make this trade, right now? This page covers what to send, what comes back, how a ruling is decided, and how a contract enforces it.

Quick start

You need a Hedera testnet account associated with USDC 0.0.429274 and a little test USDC from faucet.circle.com (enter the 0.0.x account ID). Each ruling costs one cent.

npm i naysayer
import { Naysayer } from "naysayer";

const ns = await Naysayer.fromEns("naysayer.eth", {
  payer: { accountId: "0.0.YOUR_ACCOUNT", privateKey: process.env.HEDERA_PRIVATE_KEY },
});

const v = await ns.check({
  kind: "SWAP_EXACT_IN",
  tokenIn:  "0x0000000000000000000000000000000000003ad2", // WHBAR 0.0.15058
  tokenOut: "0x0000000000000000000000000000000000001549", // USDC  0.0.5449
  amountIn: "100000000",   // 1 WHBAR, 8 decimals
  minAmountOut: "48000",   // your floor in USDC, 6 decimals
  target: "0x0000000000000000000000000000000000159398",   // SaucerSwap V2 router
});

if (!v.granted) console.log("NAY:", v.reasonName, v.hcs.url);

Prefer MCP? npx naysayer-mcp exposes one tool, naysayer_check_action. No account yet? File a free preset motion on the home page.

How a ruling is made

  1. Validate. A malformed request is rejected with 400 before any payment is asked for.
  2. Verify the payment ($0.01 USDC over x402 on hedera:testnet). It is checked, not yet taken.
  3. Deterministic checks. Token IDs against an allowlist (never names), the target, caps, oracle freshness, slippage against the oracle, the real pool quote against the oracle, and whether the vault can fund the trade. When everything else passes, Naysayer buys a second, independent HBAR price over x402 from a third-party feed and denies if it is more than 2% away from Chainlink. If the intent names a vault, the vault’s own preview is the source of truth for its mandate.
  4. The critic. A Claude model reads the result. The agent’s memo and token names are fenced as untrusted data. The critic can turn GRANTED into DENIED; no code path lets it do the reverse. It is skipped when a hard rule already denies and there is nothing untrusted to read.
  5. Write the ruling to Hedera Consensus Service and wait for its sequence number.
  6. Sign the ruling (EIP-712). The signature includes the ledger sequence number, so it commits to that ledger entry.
  7. Settle the payment. If the ledger write failed, the request ends with 503 and nothing is charged.
  8. Record the fee on the public books.

What you send

POST https://naysayer-api.vercel.app/v1/verdict with { "intent": { … } }. Amounts are decimal strings in the token’s smallest units.

kind
“SWAP_EXACT_IN” or “TRANSFER”
tokenIn, tokenOut
EVM addresses. On Hedera these are the long-zero form of the token ID. tokenOut is omitted for a transfer.
amountIn, minAmountOut
What you spend, and the least you accept. For a swap the minimum must be at or above the oracle price less the allowed slippage.
target
The router (swap) or the recipient (transfer).
poolFee
Pool fee tier, default 3000.
deadline
Unix seconds. The SDK sets five minutes from now if you leave it out.
chain, vault, nonce
Optional. Name a NaysayerVault (Hedera) or NaysayerGate (tachi:signet) and its current nonce to get a ruling that contract will accept. Without a vault, the ruling is advisory against the default mandate.
memo
Up to 280 characters: why the agent wants this. Always treated as untrusted text. It is not part of the intent hash.

What comes back

granted, reason, reasonName
The ruling and its primary reason.
codes[]
Every reason that applied, in order.
checks[]
Each check with the numbers it used: oracle price and age, the slippage floor, the pool quote.
critic
Model, vote and rationale, or why it was skipped or unavailable.
hcs
Topic, sequence number and a HashScan link to the ledger entry.
verdict, sig, signer
The EIP-712 ruling, its signature and the signing address. The SDK verifies these and returns signatureValid.
payment
The x402 settlement transaction.

HTTP status: 200 ruling returned (granted or denied) · 400 bad input, not charged · 402 payment required or not valid · 503 ledger or RPC unavailable, not charged.

Reason codes

The same numbers are used by the API, the SDK, the ledger and the contracts. Codes 32 and above come from the critic and exist off chain only, though a signed denial can carry them into a vault’s event.

codenamemeaning
0OKAll checks passed.
1PAUSEDThe vault owner paused trading.
2NOT_EXECUTORThe caller is not the vault's executor.
3TOKEN_NOT_ALLOWLISTEDA token is not on the mandate's allowlist (checked by token ID, never by name).
4TARGET_NOT_ALLOWLISTEDThe router or recipient is not on the allowlist.
5OVER_TRADE_CAPThe trade is larger than the per-trade cap.
6OVER_DAILY_CAPThe trade would exceed today's cap.
7FEED_STALEThe price oracle is older than the mandate allows.
8FEED_INVALIDThe price oracle returned an unusable answer.
9SLIPPAGE_TOO_LOOSEThe minimum output is below the oracle-implied floor.
10POOL_DRIFTThe pool quote is far worse than the oracle price.
11COOLDOWNToo soon after the last execution.
12EXPIREDThe intent's deadline has passed.
13BAD_NONCEReplay or out-of-order nonce.
14VERDICT_MISSINGThe vault requires a Naysayer verdict and none was given.
15VERDICT_INVALIDThe verdict signature, intent hash or age is wrong.
16SWAP_FAILEDThe router call failed; no funds moved.
32CRITIC_REFUSEDThe critic tightened the verdict to DENIED.
33INJECTION_SUSPECTEDInstruction-like text was found in untrusted input (memo or token metadata).

Enforcing it on chain

A ruling you can ignore is advice. NaysayerVault holds an agent’s tokens and makes the ruling binding. The owner sets a mandate (token and target allowlists, per-trade and daily caps, the oracle and its maximum age, maximum slippage, a cooldown). The agent’s key can only call execute(intent, verdict, sig); it cannot change the mandate, withdraw or pause.

  • The vault runs its own checks first, in a fixed order, then requires a fresh GRANTED ruling for that exact intent, chain and vault.
  • A refusal does not revert. It emits Decision(intentHash, false, reason, hcsSeq, …), so every “no” is a transaction anyone can inspect.
  • A valid signed DENIED ruling is enforced with Naysayer’s own reason.
  • The owner can pause the vault at any time.

NaysayerGate is the lean version on Tachi (Bitcoin Signet): the same ruling, the same signature check, and its event carries the Hedera ledger number. One verdict, two chains.

The bond

A guard that is never wrong when it says no, and never pays when it says yes, has no reason to be careful. So Naysayer locks part of what it earns in NaysayerBond. If it grants a trade and the covered vault then cannot execute it (the swap fails), the vault claims a fixed payout for the agent from the bond, inside the same transaction.

payout
0.05 USDC per failed granted ruling: five times the fee.
who can claim
Only a vault the bond covers, from inside its own execute. The bond re-checks the ruling: Naysayer's signature for that vault, GRANTED, matching the intent.
how often
Once per ledger entry.
withdrawals
Naysayer can add to the bond at any time. Taking money out waits 24 hours, so the bond cannot vanish just before a claim.
what it does not cover
A trade that executes at a poor but permitted price, or any loss outside a covered vault.

It has paid once. Ruling № 0024 granted a swap the vault could not fund; the swap failed and the agent received 0.05 USDC (transaction). The missing check was added the same hour.

Finding Naysayer

The name naysayer.eth (ENSv2, Sepolia) carries what an agent needs: where to call, who signs, where the record lives, and whom to pay. The SDK resolves the endpoint from the name and stops if the endpoint’s signer differs from the one under the name.

agent-endpoint[web]
The API base URL (ENSIP-26).
agent-context
One paragraph: what it does, the price, the ledger topic.
agent-registration[…][265]
ENSIP-25: links the name to Naysayer's ERC-8004 identity (agentId 265) in the IdentityRegistry on Hedera testnet.
naysayer.verdict-signer
The EIP-712 signing address rulings must recover to.
naysayer.hcs-verdicts
The HCS topic that holds the rulings.
naysayer.pay-to
The Hedera account that receives fees.

The same facts are served at /.well-known/agent.json. Live values are on the Integrate page.

Ledger formats

Both topics hold compact JSON, one HCS chunk each (at most 1,024 bytes). Only Naysayer’s key can write to them.

verdicts · 0.0.11727107

{"v":1,"t":"verdict","id":"<uuid>","ih":"0x<intent hash>","chain":"hedera:testnet",
 "vault":"0x…","caller":"0.0.x","g":false,"r":3,"rn":"TOKEN_NOT_ALLOWLISTED","c":[3,33],
 "crit":"haiku:DENY","a":"SWAP 0.0.15058>0.0.11692495 in=100000000 min=1",
 "d":"<numbers of the first failing check>","cr":"<the critic's rationale>",
 "px":"10000@0.0.429274","ts":1796401595}

books · 0.0.11727108

{"v":1,"t":"rev","amt":"10000","asset":"0.0.429274","from":"0.0.x","ext":true,"tx":"…","ref":"verdict:24"}
{"v":1,"t":"cost","amt":"0.000268","unit":"USD","what":"inference:claude-haiku-5-5 (…)","ref":"verdict:24"}
{"v":1,"t":"cost","amt":"50000","asset":"0.0.429274","what":"bond payout: …","tx":"0x…","ref":"verdict:24"}

ext:false marks a payment from an account we own. Those lines are never counted as revenue.

Addresses

HCS verdicts / books
0.0.11727107 / 0.0.11727108
Fee account
0.0.11699103
Verdict signer
0xd908646b42a8F77430c1E538Bf8C5cBa4C61Ac94
ERC-8004 identity
agentId 265 · IdentityRegistry 0x8004A818BFB912233c491871b3d84c89A494BD9e (Hedera testnet)
Second price source
Vouch x402 feed, usevouch.fly.dev (a third party): 0.005 USDC per purchase, paid by Naysayer
NaysayerGate (Tachi Signet)
0xecdb36f2fd40e3d76a2409809326c2fc86c32de1
ENS
naysayer.eth (ENSv2, Sepolia) · resolver 0xd1d4b7d03ee56d799d16c069c0cdb0a54623ca90
Tokens
WHBAR 0.0.15058 · USDC (SaucerSwap) 0.0.5449 · USDC (Circle, fee asset) 0.0.429274

Questions

Why pay someone else to check my agent?
A check your agent runs on itself leaves no record and binds nobody. A separate, signed ruling can be required by a vault the agent does not control, and audited later.
Can the AI approve something the rules reject?
No. The model can only make a ruling stricter. This is enforced by a small pure function with property tests.
What if Naysayer is down?
A vault that requires rulings will refuse to trade. That is the safe failure. The owner can change the mandate if they want to trade without rulings.
What if Naysayer is wrong?
A wrong “no” costs you a missed trade and one cent. A wrong “yes” on a covered vault that then fails costs Naysayer five cents from its bond.
Is this production ready?
No. Testnet only, one oracle, one signer key, no audit. See the limits.