BioVerify
DeSci Peer Review with Chainlink VRF and Durable AI Agents

Publication lifecycle
On-chain PublicationStatus state machine (BioVerify README).
Overview
Published papers often point to mutable URLs (data can change or disappear after publication). Reviewer selection is opaque, incentives for reviewers and publishers are weak, and the reproducibility crisis has eroded trust in research findings.
BioVerify is an experiment aimed at those problems. It treats peer review as a coordination game: authors stake ETH, AI screens for plagiarism, human reviewers sign their reviews, Gemini or (after an escalation) a senior reviewer sets the verdict, an agent settles it on-chain, and research artifacts are pinned to IPFS so what was reviewed stays addressable. A truth layer (BioVerifyV3) holds stakes, lifecycle, VRF-based reviewer selection, and settlement; an orchestration layer (LangGraph + Inngest) runs screening and review graphs with human-in-the-loop pauses. The contract only accepts a settlement split over reviewers who have stake locked on that publication, so the agent cannot slash arbitrary accounts, but it does decide who is honest.
Technical Architecture
BioVerify separates concerns across two layers. On-chain, BioVerifyV3 is the source of truth for stakes, publication status, reviewer selection, and settlement. Off-chain, LangGraph runs the submission and review graphs and its Postgres checkpointer carries pauses that can span days, while Inngest retries the agent runs that chain events start.
Chain events drive the app: the contract emits rich events instead of view-heavy reads for product state. Alchemy Notify POSTs logs to a verified webhook (HMAC-SHA256); processContractEvent projects into Neon Postgres with optimistic concurrency on (blockNumber, logIndex). The frontend reads the projection and uses a viem WebSocket subscription to NewPublicationStatus so open lists refetch 3 seconds after a status event, giving the projection time to catch up.
Security patterns used include CEI and OpenZeppelin nonReentrant on claim and transferSlashPoolToTreasury, pull-style claims for reviewers, verified webhooks, and EIP-712-signed peer verdicts, verified server-side before the agent records on-chain that the reviewer has reviewed.
Key features
- Stake & Submit: Scientists upload research manifests to IPFS (Pinata) and submit on-chain with a collateral stake and submission fee.
- AI Forensic Screening: A LangGraph Submission Agent fetches the abstract from IPFS, runs a neural search against academic literature via Exa AI, and produces a structured Gemini LLM verdict. A plagiarism verdict triggers immediate on-chain slashing, with no human in that step.
- VRF Reviewer Selection: If the submission passes AI screening, Chainlink VRF draws
I_VRF_NUM_WORDS = 3candidates from the staked reviewer pool; the Chainlink coordinator verifies the randomness proof on-chain before calling back BioVerifyV3. The submission fee funds the VRF subscription when screening passes, and rewards are reserved before selection. The Senior Reviewer is whichever drawn reviewer has the highest on-chain reputation (the first one drawn on a tie). - Human-in-the-Loop Peer Review: Selected reviewers submit EIP-712-signed verdicts through the frontend. Each review resumes the LangGraph Review Agent's HITL interrupt. Gemini reads the peer verdicts and returns pass, fail or an escalation to the Senior Reviewer; after escalation, code (not the prompt) forces the senior's decision.
- On-Chain Settlement: The agent counts each peer reviewer as honest (agrees with the final decision) or negligent (disagrees) and always counts the senior reviewer as honest, then settles on-chain: honest reviewers are rewarded, negligent reviewers are slashed, and the publisher's stake is returned or forfeited.
- Security Architecture: CEI pattern and nonReentrant guards on claim and transferSlashPoolToTreasury; pull-withdrawal model so settlement does not push ETH in bulk (gas-limit DoS resistance). Alchemy Notify webhooks authenticated with HMAC-SHA256 before projection. Off-chain reviewer verdicts use EIP-712 asymmetric signing (ECDSA / secp256k1).
- Event-Driven CQRS Architecture: Getter-light contract design: state mutations emit events, projected off-chain via Alchemy Notify webhooks into a Neon Postgres read model (Drizzle ORM) with optimistic concurrency control.
- Durable Agent Orchestration: LangGraph checkpointers (Postgres) let the review graph pause for days at a human-in-the-loop interrupt and resume where it left off; Inngest starts each agent run and retries it if it fails (all of the screening, and the review agent up to its first pause); after that pause, the review agent resumes in a server action with no retry.
- Live Telegram Notifications: A Telegram bot posts each status change (screening, review, settlement) on Base Sepolia and Ethereum Sepolia to one chat, as the demo recordings show.
Technologies Used
- Next.js
- TypeScript
- Solidity
- Foundry
- Chainlink
- LangGraph
- Inngest
- OpenZeppelin
- viem
- wagmi
- Reown
- IPFS
- Alchemy
- Gemini
- Exa AI
- Drizzle
- Neon
- React
- TanStack Query
- TanStack Table
- Zod
- nuqs
- shadcn/ui
- Tailwind CSS
- Solidity + Foundry + Chainlink VRF: BioVerifyV3 smart contract with staking, slashing, VRF-based reviewer selection, an O(1) swap-and-pop reviewer pool, and on-chain settlement. 50 Foundry tests.
- Next.js + TypeScript + wagmi + Reown AppKit: DApp frontend with wallet integration, EIP-712 typed data signing, and real-time event-driven UI.
- TanStack Query + TanStack Table + nuqs: Reactive UI data layer: TanStack Query caches server queries and invalidates on
NewPublicationStatusWSS events; TanStack Table plus components from the Niko Table registry (shadcn-style) power the/publicationsdata grid; nuqs syncs filters and pagination to URL state. - LangGraph.js + Gemini + Exa AI: Stateful AI agents for submission forensics (plagiarism detection via neural search) and review orchestration with HITL interrupts.
- Inngest: Retries around each agent run that a chain event starts: the submission agent (screening, then the earlySlash call or the pickReviewers call that requests the draw) and the start of the review agent.
- Drizzle ORM + Neon Postgres: CQRS read model projected from contract events, with optimistic concurrency control; it serves the app's product queries.
- Alchemy Notify: HMAC-verified webhooks projecting contract events into the off-chain read model in real time.
- OpenZeppelin: ReentrancyGuard on claim and transferSlashPoolToTreasury: OpenZeppelin's guard instead of a hand-rolled one.
Challenges and Learnings
Orchestrating durable agents across asynchronous human review: LangGraph checkpointers let the workflow pause for days and resume at the same human-in-the-loop interrupt. A getter-light, event-emitted contract required tight alignment between on-chain emissions and Neon Postgres projections via Alchemy Notify; optimistic concurrency on (blockNumber, logIndex) keeps a repeated webhook delivery from changing the read model, though a repeated SubmitPublication would start a second screening run. I kept Inngest to starting and retrying the agent runs that chain events trigger, and the pause itself in LangGraph state; a retried screening re-runs the whole agent, so its commands read state before writing where they can.
Outcome
BioVerify demonstrates an end-to-end DeSci peer-review pipeline on Base Sepolia and Ethereum Sepolia: stake and submit, AI plagiarism screening, Chainlink VRF reviewer selection, human review with escalation, and on-chain settlement with explicit incentives. I built it to learn how long-running agents and a Solidity contract work together; it is not meant for real scientific publishing.
Key Metrics
- Deployments: Base Sepolia and Ethereum Sepolia, contract source verified on the block explorers (addresses in the README)
- Tests: BioVerifyV3, 50 Foundry tests across 12 suites, in 11 files, including VRF edge cases (collisions, pool shrinking and rewards running out during VRF);
forge coverageon 24 October 2026: 100% of the lines (240/240), branches (37/37) and functions ofsrc/BioVerifyV3.sol - Read path: Product queries served from the Neon Postgres projection; lists update over WebSocket, the detail view polls every 10 s until the publication is final
Transferable patterns: The same event projection and long-running agent workflow would fit DAO tooling or marketplaces.
Known limitations
- Settlement is trusted to one agent key: a single immutable agent address drives every transition (pick reviewers, early slash, publish or slash), and on both deployments the agent address is also the treasury and the owner, who can change the VRF coordinator. The contract limits whom it can slash, not the verdict.
- LLM decisions without a human: the plagiarism early-slash is one Gemini call over Exa's top results, and without escalation Gemini decides pass or fail from the peer reviews; reviewers who disagree with it are slashed. Signed reviews are verified off-chain and the signatures are not kept: the contract stores only a bool per review, and the checkpoint database keeps each review's address, decision and reason.
- Contract edge cases:
pickReviewerschecksstatus != IN_REVIEWinstead of== SUBMITTED, so the agent could re-open a finished publication and re-sendpaidSubmissionFee(untested); if the reviewer pool shrinks or rewards run out between the VRF request and fulfilment, the callback reverts and the publication stays IN_REVIEW (VRF does not retry); collision handling by linear probing slightly biases the draw; an early-slashed submission's fee stays in the contract, outside both pools, and nothing in the normal flow moves it. - Read model: each row carries one (block, logIndex) stamp while updates touch some columns, so a late event changing a different field is dropped; failed projections after the webhook's 200 are lost, with no replay job yet; the projection follows the chain tip with no confirmation depth; the webhook's HMAC is compared with
===, not in constant time. - IPFS reads trust the gateway: the agent fetches content through the Pinata gateway and does not re-hash it against the CID.
- No author recourse against false positives: The submission agent can produce a false plagiarism verdict, and peer review can reach a binding decision the author considers incorrect. Today both paths are terminal (immediate
earlySlashPublicationorslashPublication); there is no contract-level mechanism for the author to contest, post an escalation stake, or trigger a second human-only review. - IPFS / manifest edge cases: A syntactically valid CID that resolves to an empty or malformed manifest can leave the submission graph without a clean pass/fail path; after Inngest's 3 retries the publication stays stuck in SUBMITTED.
- Agent transaction failures: On-chain commands use simulate-then-write with no gas bump or nonce recovery. Settlement runs in the Next.js server action that resumes the last review, with no retry, so a gas spike can leave a publication in IN_REVIEW after the last human review is recorded.
- No reviewer deadline: the review graph waits for every reviewer and the contract has no timeout, so a reviewer who never answers leaves the publication IN_REVIEW, with every stake locked.
- Chain support is hardcoded: the two networks are a fixed enum used across the codebase; adding a chain means a new deployment plus changes in several places.
- Testing depth: only the contract has automated tests; the agents, the read model and the frontend have none.
Roadmap
- Less trust in the agent: Separate the agent, the treasury and the owner, and record each review's signature on-chain so the contract can check who voted what.
- Weighted majority voting: Replace the senior tie-break with consensus weighted by on-chain reputation.
- ZK reputation (Reclaim Protocol): Privacy-preserving proofs of real-world signals without exposing raw credentials.
- Encrypted access (Lit Protocol) and monetisation (x402): Encrypt IPFS payloads with on-chain conditional decryption; gate datasets and supplementary material behind micropayments.
- Internal corpus + RAG: Index published manifests in Neon + pgvector alongside Exa AI for similarity checks.
- Author escalation path: Let an author contest a verdict (AI early-slash or peer-review settlement) within a bounded escalation window by posting a larger escalation stake. The contract opens a second review cycle restricted to humans only, with a fresh VRF cohort that excludes the original reviewers. The second verdict is binding and reconciles the first: if confirmed, the escalation stake is slashed on top of the original; if overturned, prior rewards and slashes are reversed and recomputed against the new verdict. This requires a settlement-enforcement delay (escalation window) before terminal states become final.