@agentbadge/verify-verdict
v0.1.0
Published
Standalone on-chain verifier for AgentBadge verdicts — memo anchors + hash-chain head anchors, no server calls
Maintainers
Readme
@agentbadge/verify-verdict
Standalone on-chain verifier for AgentBadge verdicts. Level-2 trust:
re-checks every claim against the chain itself — zero calls to the
AgentBadge server (Level-1 is GET /api/verify/:verdictId).
Install
npm i @agentbadge/verify-verdict
# or run directly
npx @agentbadge/verify-verdict <verdictId|txHash>CLI
verify-verdict <verdictId|txHash> [options]
--rpc <url> RPC endpoint (default: $VERIFY_RPC_URL or Arc testnet)
--artifact <file> verdict artifact JSON → memoData tamper check
--entries <file> chain entries JSON → local head recompute + inclusion
--domain <name> chain domain (default: eaas-verdicts)
--epochs <a,b> check specific head-anchor epochs (default: latest)
--no-head skip head-anchor proofs
--memo <address> memo contract override
--json machine-readable outputAmbiguous 0x… input is tried as verdictId first, then txHash.
Exit codes: 0 — every executed proof passed; 1 — invalid,
unanchored, or a typed error (see below). There is no "trusted" exit
path — RPC failure exits 1 with rpc_unavailable, never fake-valid.
Library
import { verifyVerdict } from "@agentbadge/verify-verdict";
const r = await verifyVerdict({
verdictId: "0x…",
rpcUrl: "https://rpc.testnet.arc.network", // or $VERIFY_RPC_URL
artifact, // optional → memoData === artifactHashOf(artifact)
entries, // optional → local chain recompute + head cross-check
headEpochs: "latest", // "none" | [0, 1, …]
});
// r = { valid, verdictId, proofs[], headAnchor?, timestamp }proofs[] — one entry per checked layer (names match PROOF_KINDS_V1
on the server): verdict (per-verdict memo anchor), anchor-tx,
anchor-head (epoch head anchor), chain-recompute (caller-supplied
entries folded over computeEntryHash — primitive imported from
@agentbadge/circle-payments, not copied).
valid === proofs.every(ok). RPC failure throws
VerifyError("rpc_unavailable"); malformed input →
VerifyError("invalid_input") — typed, honest, never a verdict.
On-chain layout
| Proof | memoId | memoData |
|---|---|---|
| verdict anchor | memoIdFor("eaas", verdictId) | artifactHash (keccak256 canonicalJson) |
| head anchor | memoIdFor("chain", domain, epochSeq) | abiEncode(headHash, count, prevAnchoredHeadHash) |
Memo contract (Arc mainnet+testnet): 0x5294E9927c3306DcBaDb03fe70b92e01cCede505.
Env
VERIFY_RPC_URL— default RPC for CLI anddefaultReadClient(). Falls back tohttps://rpc.testnet.arc.network(O1).
Deps: viem + @agentbadge/circle-payments only. MIT.
