<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: The Web3 Wizard</title>
    <description>The latest articles on DEV Community by The Web3 Wizard (@theweb3wizard00).</description>
    <link>https://dev.to/theweb3wizard00</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4191875%2Fab07f561-61ee-4aa8-adb5-68f0ad1cdfb7.png</url>
      <title>DEV Community: The Web3 Wizard</title>
      <link>https://dev.to/theweb3wizard00</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/theweb3wizard00"/>
    <language>en</language>
    <item>
      <title>I Built an Open-Source Safe Multisig Sentinel in n8n (Without Giving an AI Private Keys)</title>
      <dc:creator>The Web3 Wizard</dc:creator>
      <pubDate>Sun, 08 Nov 2026 07:31:11 +0000</pubDate>
      <link>https://dev.to/theweb3wizard00/i-built-an-open-source-safe-multisig-sentinel-in-n8n-without-giving-an-ai-private-keys-2b73</link>
      <guid>https://dev.to/theweb3wizard00/i-built-an-open-source-safe-multisig-sentinel-in-n8n-without-giving-an-ai-private-keys-2b73</guid>
      <description>&lt;p&gt;Picture this scenario.&lt;/p&gt;

&lt;p&gt;You are one of four signers on a protocol treasury holding twelve million dollars in digital assets. It is 3:15 AM on a Tuesday. Your phone buzzes with a Safe notification:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Pending multisig transaction: 1 of 3 signatures confirmed.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You open the Safe web app on your phone, half-asleep. The destination is an unverified proxy contract ending in &lt;code&gt;...f9c2&lt;/code&gt;. The function selector is &lt;code&gt;0x8c5be1e5&lt;/code&gt;, followed by two kilobytes of hex-encoded calldata. The proposer is one of your co-signers who lives six time zones away.&lt;/p&gt;

&lt;p&gt;Do you sign it?&lt;/p&gt;

&lt;p&gt;Be honest. Most signers click "Approve" on their hardware wallet. They trust their peer. They assume someone else checked the calldata. They tell themselves they will review the transaction receipt in the morning.&lt;/p&gt;

&lt;p&gt;That is how Web3 treasuries get drained.&lt;/p&gt;

&lt;p&gt;Not because someone cracked elliptic-curve cryptography. Treasuries get drained because of human operational fatigue, time-zone drag, and blind signing.&lt;/p&gt;

&lt;p&gt;Today, I built an open-source tool to solve this: &lt;strong&gt;The Safe &amp;amp; Treasury Sentinel&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is a self-hostable, automated monitoring workflow built in n8n. It receives live Safe Infrastructure webhooks, runs a 15-minute scheduled state reconciliation, diffs your live wallet configuration against an approved baseline, and uses an AI agent to explain the calldata in plain English.&lt;/p&gt;

&lt;p&gt;Most importantly: &lt;strong&gt;it does not touch a single private key.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is the exact architecture, the code, the trade-offs, and how you can run it yourself.&lt;/p&gt;




&lt;h2&gt;
  
  
  The AI Agent Trap in Web3
&lt;/h2&gt;

&lt;p&gt;Every week on Twitter, someone shows off an "autonomous AI crypto agent."&lt;/p&gt;

&lt;p&gt;The video is always the same: a developer writes a Python script, drops an OpenAI API key into a &lt;code&gt;.env&lt;/code&gt; file, connects an Ethereum wallet with twenty dollars of testnet ETH, and asks the bot to swap tokens on Uniswap. Everyone claps.&lt;/p&gt;

&lt;p&gt;I think giving an LLM an unrestricted private key is an accident waiting to happen.&lt;/p&gt;

&lt;p&gt;Large language models are probabilistic text predictors. They are not deterministic state machines. They misinterpret ambiguous inputs. They hallucinate addresses. They are vulnerable to prompt injections hidden in on-chain transaction strings.&lt;/p&gt;

&lt;p&gt;Blockchains are the exact opposite. Every transaction is binary, permanent, and mathematically final. Once your treasury tokens leave your Safe, no customer support team can reverse the transfer.&lt;/p&gt;

&lt;p&gt;If you connect a probabilistic AI model directly to an irreversible execution wallet, you are asking to get wiped out.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Correct Mental Model
&lt;/h3&gt;

&lt;p&gt;You do not need an AI with signing authority.&lt;/p&gt;

&lt;p&gt;You need an automated sentinel that handles the tedious operational grunt work:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ingesting event notifications 24/7 so humans do not have to refresh Safe all day.&lt;/li&gt;
&lt;li&gt;Checking deterministic rules (Did the threshold change? Is this a &lt;code&gt;DELEGATECALL&lt;/code&gt;? Is the recipient allowlisted?).&lt;/li&gt;
&lt;li&gt;Using an AI model strictly as an &lt;strong&gt;explanation analyst&lt;/strong&gt; to translate raw bytecode into human-readable briefs.&lt;/li&gt;
&lt;li&gt;Keeping all signing power in the hands of human multisig signers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The AI proposes and explains. The blockchain and humans enforce.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why n8n?
&lt;/h2&gt;

&lt;p&gt;When I sat down to build this, I could have built a standalone microservice using Express, TypeScript, and a dedicated PostgreSQL database.&lt;/p&gt;

&lt;p&gt;I deliberately chose &lt;strong&gt;n8n&lt;/strong&gt; instead.&lt;/p&gt;

&lt;p&gt;Why? Because operational tooling for crypto teams needs to be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inspectable:&lt;/strong&gt; Every node in the canvas can be visually audited by non-developers on the finance council.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-Hostable:&lt;/strong&gt; Teams can run it on their own private VPS or Docker container with zero third-party data leakage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extensible:&lt;/strong&gt; It ships with native HTTP request nodes, Cron schedulers, built-in Data Tables for persistence, and AI Agent nodes out of the box.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portable:&lt;/strong&gt; The entire system lives in a single JSON file (&lt;code&gt;workflow/safe-treasury-sentinel.json&lt;/code&gt;). You import it into your n8n canvas, connect your credentials, and you are ready.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The System Architecture
&lt;/h2&gt;

&lt;p&gt;The Sentinel operates across three distinct triggers:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    A[Safe Event Webhook] --&amp;gt; B[Validate &amp;amp; Deduplicate]
    B --&amp;gt; C[Fetch Safe State &amp;amp; TX Details]
    C --&amp;gt; D[Deterministic Policy Engine]

    E[15-Minute Scheduled Cron] --&amp;gt; F[Fetch Current Safe State &amp;amp; Balances]
    F --&amp;gt; G[Diff Against Approved Baseline]
    G --&amp;gt; D

    H[Manual Demo Trigger] --&amp;gt; I[Synthetic Test Scenarios]
    I --&amp;gt; D

    D --&amp;gt; J[Evidence-Led Brief]
    J --&amp;gt; K[n8n AI Incident Analyst]
    K --&amp;gt; L[Record in n8n Data Table]
    L --&amp;gt; M[Optional Telegram Alert]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Let's break down how the core pieces work under the hood.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Webhook Ingestion &amp;amp; Deduplication
&lt;/h2&gt;

&lt;p&gt;Safe Infrastructure provides a webhook service that emits HTTP POST events whenever activity happens on your multisig.&lt;/p&gt;

&lt;p&gt;The Sentinel exposes an authenticated webhook endpoint that listens for seven event categories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;PENDING_MULTISIG_TRANSACTION&lt;/code&gt; (a new proposal was submitted)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;NEW_CONFIRMATION&lt;/code&gt; (a signer approved a proposal)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;EXECUTED_MULTISIG_TRANSACTION&lt;/code&gt; (the transaction executed on-chain)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;NEW_DELEGATE&lt;/code&gt; / &lt;code&gt;UPDATED_DELEGATE&lt;/code&gt; / &lt;code&gt;DELETED_DELEGATE&lt;/code&gt; (access-control changes)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MODULE_TRANSACTION&lt;/code&gt; (an automated smart account module moved funds)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OUTGOING_ETHER&lt;/code&gt; / &lt;code&gt;OUTGOING_TOKEN&lt;/code&gt; (funds left the treasury)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;REORG_DETECTED&lt;/code&gt; (a chain reorganization occurred)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because distributed webhook deliverers can send duplicate messages during network retries, the workflow normalizes an event delivery identifier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;deliveryId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; 
  &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;safeTxHash&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; 
  &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;txHash&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; 
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;safeAddress&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;timestamp&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It checks this identifier against an internal &lt;code&gt;SafeSentinelDeliveries&lt;/code&gt; Data Table. If the delivery was already processed, it drops the duplicate immediately.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. The 15-Minute Scheduled Baseline Reconciler
&lt;/h2&gt;

&lt;p&gt;Webhooks are push notifications. What happens if Safe's webhook service experiences an outage?&lt;/p&gt;

&lt;p&gt;That is why the Sentinel has a secondary, pull-based heartbeat. Every 15 minutes, a scheduled cron trigger fires. It queries the Safe Transaction Service API directly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retrieves current owners and threshold.&lt;/li&gt;
&lt;li&gt;Pulls active modules and guard contracts.&lt;/li&gt;
&lt;li&gt;Retrieves the delegate registry.&lt;/li&gt;
&lt;li&gt;Checks pending multisig transactions.&lt;/li&gt;
&lt;li&gt;Ingests current ERC-20 token balances.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Catching Stealth Configuration Drifts
&lt;/h3&gt;

&lt;p&gt;When you first deploy the Sentinel, you click a manual trigger called &lt;code&gt;Capture Approved Treasury Baseline&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This snapshots your wallet's verified reference configuration into an n8n Data Table (&lt;code&gt;SafeSentinelBaselines&lt;/code&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Approved owners list&lt;/li&gt;
&lt;li&gt;Signing threshold (e.g., 3 of 5)&lt;/li&gt;
&lt;li&gt;Enabled modules&lt;/li&gt;
&lt;li&gt;Authorized delegates&lt;/li&gt;
&lt;li&gt;Guard contract address&lt;/li&gt;
&lt;li&gt;Fallback handler and master copy implementation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every 15 minutes, the scheduled reconciler diffs the live Safe state against this approved baseline.&lt;/p&gt;

&lt;p&gt;If an attacker compromises enough keys to submit a transaction that lowers your threshold from 3-of-5 to 1-of-5, or quietly enables a rogue Safe module, the reconciler catches the drift on the next cycle, flags it as &lt;code&gt;CRITICAL&lt;/code&gt;, and raises an alarm.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. The Deterministic Policy Engine (Before the AI Sees It)
&lt;/h2&gt;

&lt;p&gt;Here is a foundational engineering rule: &lt;strong&gt;Never let an LLM decide whether an event is dangerous.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Large language models can be persuaded. Math and code cannot.&lt;/p&gt;

&lt;p&gt;Before any data reaches the AI layer, our workflow routes all transactions through a JavaScript code node called the &lt;code&gt;Deterministic Event Policy Engine&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This engine assigns an initial severity (&lt;code&gt;INFO&lt;/code&gt;, &lt;code&gt;MEDIUM&lt;/code&gt;, &lt;code&gt;HIGH&lt;/code&gt;, &lt;code&gt;CRITICAL&lt;/code&gt;) and a numerical risk score (0 to 100) based on strict, deterministic rules.&lt;/p&gt;

&lt;p&gt;Here is a look at the policy logic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Excerpt from Deterministic Event Policy Engine&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;severity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;INFO&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;reasons&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;reviewRequired&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 1. Rogue Module Execution&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MODULE_TRANSACTION&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;severity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CRITICAL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;reasons&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;A Safe module executed an action. Modules bypass multisig thresholds completely.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;reviewRequired&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// 2. Dangerous DELEGATECALL Detection&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;operation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;severity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CRITICAL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;reasons&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Transaction uses DELEGATECALL. This allows the target contract to rewrite Safe storage.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;reviewRequired&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// 3. Unapproved Recipient Check&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;approvedRecipients&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;severity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;HIGH&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;reasons&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Recipient address is not in the configured approved-destination list.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;reviewRequired&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// 4. Large Native Outflow&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;OUTGOING_ETHER&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nc"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;valueWei&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;BigInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;maxNativeTransferWei&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;severity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;HIGH&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;score&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;88&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;reasons&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Native ETH transfer exceeds the configured single-transaction ceiling.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;reviewRequired&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the check for &lt;code&gt;tx.operation === 1&lt;/code&gt;. In Safe contracts, operation &lt;code&gt;0&lt;/code&gt; is a standard &lt;code&gt;CALL&lt;/code&gt;, while operation &lt;code&gt;1&lt;/code&gt; is a &lt;code&gt;DELEGATECALL&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If a pending transaction uses &lt;code&gt;DELEGATECALL&lt;/code&gt;, the target contract executes in the context of your Safe's storage. It can overwrite the owner array or self-destruct the contract. The policy engine instantly flags this as a 99-score &lt;code&gt;CRITICAL&lt;/code&gt; risk before any AI prompt is generated.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. The AI Incident Analyst (The Plain-English Explainer)
&lt;/h2&gt;

&lt;p&gt;Only after the deterministic facts, baseline diffs, and risk scores are assembled does the workflow pass the packet to the n8n AI Agent node.&lt;/p&gt;

&lt;p&gt;The AI Agent connects to OpenAI (&lt;code&gt;gpt-4.1-mini&lt;/code&gt;) with a strictly bounded system prompt:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Explain the facts:&lt;/strong&gt; Summarize what happened in clear, developer-friendly prose.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Never downgrade:&lt;/strong&gt; The AI is forbidden from lowering the severity assigned by the deterministic rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Highlight missing data:&lt;/strong&gt; If a webhook arrived without recipient details or calldata, explicitly say so.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Action checklist:&lt;/strong&gt; Provide a 3-point verification checklist for human signers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is an example of what the AI output looks like when it flags an unapproved recipient proposal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CRITICAL ALERT: Safe Proposal Requires Signer Review
Safe: 0x12a4...b891 (Ethereum Mainnet)
Severity: HIGH | Risk Score: 90/100

Summary:
A new pending multisig transaction (nonce 42) was submitted by signer 0x89c...d41. 
The transaction proposes transferring 50,000 USDC to 0x742...12a.

Findings:
- Destination 0x742...12a is NOT in the approved treasury recipient list.
- Value: 50,000.00 USDC.
- Current signatures: 1 of 3 required.

Signer Checklist Before Approving:
1. Contact proposer 0x89c...d41 on an out-of-band communication channel (Signal/phone).
2. Confirm whether destination 0x742...12a belongs to an approved vendor invoice.
3. Verify that the transaction calldata matches the expected ERC-20 transfer selector.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  5. Persistence &amp;amp; Alerts
&lt;/h2&gt;

&lt;p&gt;Every incident is persisted into an n8n Data Table called &lt;code&gt;SafeSentinelIncidents&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This gives your operations team a queryable, permanent ledger of every alert, risk score, transaction hash, and AI explanation. If you configure a Telegram Bot token and chat ID in the settings, it formats the summary and pings your security channel instantly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Honest Limitations: What This v1 Does NOT Do
&lt;/h2&gt;

&lt;p&gt;I want to be completely transparent about what this repository is and what it is not.&lt;/p&gt;

&lt;p&gt;It is a functional reference implementation and proof of capability. It is not an audited commercial product.&lt;/p&gt;

&lt;p&gt;Here are the real limitations you should know before running it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Single-Chain Starter:&lt;/strong&gt; The initial template is configured for one Safe on Ethereum Mainnet (&lt;code&gt;chainId: 1&lt;/code&gt;). If you run on Arbitrum, Base, or Optimism, you must update the service base URLs and chain IDs together.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delivery Acknowledgment Timing:&lt;/strong&gt; In the starter workflow, the webhook response is returned early to prevent Safe's webhook server from timing out. If downstream AI inference fails due to an OpenAI API error, the delivery was recorded, but the incident row might lack the full AI summary. A full production deployment requires a dead-letter replay queue.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Baselines Need Honest Humans:&lt;/strong&gt; If your Safe is already compromised when you click &lt;code&gt;Capture Approved Treasury Baseline&lt;/code&gt;, the Sentinel will snapshot the compromised state as the approved baseline. A human must independently verify the wallet on Etherscan before running baseline capture.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read-Only by Design:&lt;/strong&gt; The Sentinel cannot pause your Safe, cancel proposals, or move funds. It has zero keys. It is a watchdog, not an execution bot.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  How to Try It Yourself
&lt;/h2&gt;

&lt;p&gt;The entire project is open-source under the MIT license.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Clone the Repo
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/theweb3wizard/safe-treasury-sentinel.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Import into n8n
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open your n8n canvas.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Workflow -&amp;gt; Import from File&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;code&gt;workflow/safe-treasury-sentinel.json&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 3: Configure Settings
&lt;/h3&gt;

&lt;p&gt;Open the central configuration node labeled &lt;code&gt;Configuration &amp;amp; Input Router - EDIT SAFE SETTINGS HERE&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set your &lt;code&gt;safeAddress&lt;/code&gt; and &lt;code&gt;chainId&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Paste your verified &lt;code&gt;approvedRecipients&lt;/code&gt; array.&lt;/li&gt;
&lt;li&gt;Connect your OpenAI credential to the AI node.&lt;/li&gt;
&lt;li&gt;Assign your Safe Transaction Service API headers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 4: Run the Demo
&lt;/h3&gt;

&lt;p&gt;Hit the &lt;code&gt;Run Demo Scenarios...&lt;/code&gt; manual trigger. It feeds four synthetic scenarios (a rogue module execution, an unapproved recipient proposal, a native transfer spike, and a routine confirmation) through the engine so you can watch how the deterministic rules and AI analyst respond.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;You do not need to build hundred-thousand-dollar custom microservices to maintain visibility over your treasury. And you certainly should not be giving private keys to language model loops.&lt;/p&gt;

&lt;p&gt;By combining low-code workflow automation with deterministic policy checks and an isolated AI analyst, you get 24/7 surveillance while keeping your treasury's private keys safely locked inside your hardware wallets.&lt;/p&gt;

&lt;p&gt;Check out the code on GitHub:&lt;br&gt;
&lt;a href="https://github.com/theweb3wizard/safe-treasury-sentinel" rel="noopener noreferrer"&gt;https://github.com/theweb3wizard/safe-treasury-sentinel&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are running a protocol treasury or building Web3 automations, I would love to hear your feedback. What rules would you add to the policy engine?&lt;/p&gt;

</description>
      <category>web3</category>
      <category>ethereum</category>
      <category>security</category>
      <category>ai</category>
    </item>
    <item>
      <title>Why AI Coding Agents Hallucinate on EVM Bugs (And How We Packaged 5 Testable Skills to Fix It)</title>
      <dc:creator>The Web3 Wizard</dc:creator>
      <pubDate>Mon, 19 Oct 2026 02:19:25 +0000</pubDate>
      <link>https://dev.to/theweb3wizard00/why-ai-coding-agents-hallucinate-on-evm-bugs-and-how-we-packaged-5-testable-skills-to-fix-it-4pha</link>
      <guid>https://dev.to/theweb3wizard00/why-ai-coding-agents-hallucinate-on-evm-bugs-and-how-we-packaged-5-testable-skills-to-fix-it-4pha</guid>
      <description>&lt;p&gt;If you have tried using Claude Code, Cursor, or ChatGPT to debug a reverting Solidity transaction or write Foundry invariants, you have probably watched this sequence play out:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You feed the agent an error message or a raw transaction hash.&lt;/li&gt;
&lt;li&gt;The model apologizes, guesses three different reasons why the call might have failed, and suggests rewriting a functioning helper contract.&lt;/li&gt;
&lt;li&gt;If you ask it to generate an invariant test, it hallucinates a stateless property or creates a ghost variable that passes without ever touching real contract storage.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The problem isn't that current LLMs lack Solidity knowledge. The problem is that &lt;strong&gt;general-purpose coding agents lack a repeatable, evidence-first workflow for Web3 systems.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Web3, a wrong suggestion isn't just a syntax error that fails the build. It can mean an unhandled reorg, an unauthorized external call, or a misconfigured slippage parameter.&lt;/p&gt;

&lt;p&gt;To fix this, we structured and open-sourced &lt;strong&gt;Spellbook Skills&lt;/strong&gt;: five testable, deterministic workflow packs designed for AI coding agents like Claude Code, Cursor, and Antigravity.&lt;/p&gt;

&lt;p&gt;Here is why coding agents fail on EVM tasks, how structured skills change their behavior, and how you can install them today.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Core Problem: Reasoning Without Evidence
&lt;/h2&gt;

&lt;p&gt;When a human smart contract engineer investigates a revert, they follow a systematic loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Get tx receipt → Decode custom error selector → Pull trace via `cast run` → Inspect storage slot / state → Form hypothesis → Write reproducible test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When an unguided AI agent tries to do the same task, it skips directly from &lt;strong&gt;raw error → proposed code edit&lt;/strong&gt;. It relies on pattern-matching against training data rather than verifying the actual state on-chain.&lt;/p&gt;

&lt;p&gt;To make an agent reliable, you don't need a larger prompt. You need to constrain the agent with &lt;strong&gt;four operational boundaries&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Evidence before conclusions:&lt;/strong&gt; The agent must pull the revert reason or &lt;code&gt;cast run&lt;/code&gt; trace before suggesting code modifications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Strict separation of roles:&lt;/strong&gt; Scaffolding a test is different from verifying a vulnerability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero secret handling:&lt;/strong&gt; An agent must never ask for, log, or accept private keys, mnemonic phrases, or live signer credentials.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deny-by-default execution:&lt;/strong&gt; Any on-chain action or transaction proposal must pass an explicit policy gate before it can be executed.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The 5 Skills We Packaged
&lt;/h2&gt;

&lt;p&gt;Rather than building a monolithic "all-in-one Web3 agent," we built five focused skills. Each skill contains a &lt;code&gt;SKILL.md&lt;/code&gt; operating specification, reference check-lists, test fixtures, and runnable helpers.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;code&gt;evm-tx-failure-diagnoser&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it targets:&lt;/strong&gt; Cryptic reverts, custom error selectors, gas exhaustion, and nonce collisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The workflow:&lt;/strong&gt; It prevents the agent from guessing. The agent is forced to decode the 4-byte error selector, fetch the trace via &lt;code&gt;cast run &amp;lt;TX_HASH&amp;gt;&lt;/code&gt; or local RPC, isolate the failing call frame, and document the root cause before touching contract files.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. &lt;code&gt;foundry-invariant-scaffold&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it targets:&lt;/strong&gt; Brittle unit tests that miss edge-case multi-step exploits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The workflow:&lt;/strong&gt; Guides the agent through setting up genuine stateful fuzzing in Foundry. It scaffolds dedicated handler contracts, defines actor proxies, bounds inputs with realistic ghost variables, and structures assertions that check system-level invariants across sequences of calls.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. &lt;code&gt;web3-agent-tx-safety&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it targets:&lt;/strong&gt; Autonomous agents that propose or broadcast transactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The workflow:&lt;/strong&gt; Implements a strict, deny-by-default transaction policy gate. Every transaction payload must pass through parameter bounds (target allowlist, max value, calldata selector inspection) and a simulated dry-run before any signing payload can be constructed.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. &lt;code&gt;slither-finding-verifier&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it targets:&lt;/strong&gt; Static analysis triage fatigue and false positives.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The workflow:&lt;/strong&gt; Takes raw Slither JSON output and normalizes it into a triage worksheet. It requires the agent to verify the finding against actual source AST before generating a targeted, reproducible test case that confirms whether the vulnerability is exploitable or benign.&lt;/p&gt;




&lt;h3&gt;
  
  
  5. &lt;code&gt;rpc-event-reliability&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What it targets:&lt;/strong&gt; Event listeners that miss logs during network congestion or reorgs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The workflow:&lt;/strong&gt; Hardens log ingestion backends. It structures durable event deduplication keys (&lt;code&gt;chain + blockHash + txHash + logIndex&lt;/code&gt;), configures Viem fallback transports, and builds reorg reconciliation routines that handle chain reorganizations gracefully.&lt;/p&gt;




&lt;h2&gt;
  
  
  How to Install and Use Them
&lt;/h2&gt;

&lt;p&gt;All five skills are open-source under the &lt;strong&gt;MIT License&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you use the &lt;code&gt;skills&lt;/code&gt; CLI, you can install any of them directly into your agent's workspace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install the EVM Diagnoser for Claude Code&lt;/span&gt;
npx skills add theweb3wizard/spellbook-skills &lt;span class="nt"&gt;--skill&lt;/span&gt; evm-tx-failure-diagnoser &lt;span class="nt"&gt;-a&lt;/span&gt; claude-code

&lt;span class="c"&gt;# Install the Foundry Invariant Scaffolder&lt;/span&gt;
npx skills add theweb3wizard/spellbook-skills &lt;span class="nt"&gt;--skill&lt;/span&gt; foundry-invariant-scaffold &lt;span class="nt"&gt;-a&lt;/span&gt; claude-code

&lt;span class="c"&gt;# Or install all 5 skills into your project&lt;/span&gt;
npx skills add theweb3wizard/spellbook-skills &lt;span class="nt"&gt;--skill&lt;/span&gt; &lt;span class="s1"&gt;'*'&lt;/span&gt; &lt;span class="nt"&gt;-a&lt;/span&gt; claude-code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Manual Installation
&lt;/h3&gt;

&lt;p&gt;You can also clone the repository and drop the skill directories directly into your workspace:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Claude Code:&lt;/strong&gt; &lt;code&gt;.claude/skills/&amp;lt;skill-name&amp;gt;/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cursor / Codex:&lt;/strong&gt; &lt;code&gt;.agents/skills/&amp;lt;skill-name&amp;gt;/&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/theweb3wizard/spellbook-skills.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Example: What a Guarded Agent Run Looks Like
&lt;/h2&gt;

&lt;p&gt;Here is what happens when you prompt an agent equipped with &lt;code&gt;evm-tx-failure-diagnoser&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prompt:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Our deposit transaction reverted on Base: &lt;code&gt;0x7a8b...3f1c&lt;/code&gt;. Figure out why and tell me what needs fixing."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Without the skill:&lt;/strong&gt;&lt;br&gt;
The agent often guesses: &lt;em&gt;"It looks like you didn't approve the ERC20 token first, or the contract is paused."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With the skill:&lt;/strong&gt;&lt;br&gt;
The agent executes the diagnostic workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It queries the transaction receipt and extracts the revert data: &lt;code&gt;0x118cdaa7&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It decodes the selector against the project ABI: &lt;code&gt;InsufficientCollateral(uint256 current, uint256 required)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;It notes that the required collateral threshold was calculated using an oracle timestamp older than the protocol's staleness tolerance (&lt;code&gt;maxOracleDelay = 3600&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;It outputs an evidence-backed triage report and suggests a regression test fixture rather than blindly editing contract code.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Open Source &amp;amp; Community Feedback
&lt;/h2&gt;

&lt;p&gt;We built these skills as part of our work at &lt;strong&gt;&lt;a href="https://spellbook.theweb3wizard.xyz/" rel="noopener noreferrer"&gt;Spellbook&lt;/a&gt;&lt;/strong&gt;, where we design and deploy production-ready AI agents for Web3 protocols.&lt;/p&gt;

&lt;p&gt;The skills are completely free and testable offline. You can review the full code, test suites, and workflows here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🐙 &lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/theweb3wizard/spellbook-skills" rel="noopener noreferrer"&gt;github.com/theweb3wizard/spellbook-skills&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📖 &lt;strong&gt;Interactive Skills Directory:&lt;/strong&gt; &lt;a href="https://spellbook.theweb3wizard.xyz/skills" rel="noopener noreferrer"&gt;spellbook.theweb3wizard.xyz/skills&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you test them out on your smart contract projects, drop a reaction or let me know what other recurring Web3 workflows your agents struggle with in the comments below!&lt;/p&gt;

</description>
      <category>web3</category>
      <category>solidity</category>
      <category>ethereum</category>
      <category>ai</category>
    </item>
    <item>
      <title>Why Vector Search Guesses and Graphs Prove: What Building ClearPath Taught Me</title>
      <dc:creator>The Web3 Wizard</dc:creator>
      <pubDate>Sun, 18 Oct 2026 10:14:48 +0000</pubDate>
      <link>https://dev.to/theweb3wizard00/why-vector-search-guesses-and-graphs-prove-what-building-clearpath-taught-me-42lj</link>
      <guid>https://dev.to/theweb3wizard00/why-vector-search-guesses-and-graphs-prove-what-building-clearpath-taught-me-42lj</guid>
      <description>&lt;p&gt;Let’s talk about something I see over and over in Web3 and AI right now.&lt;/p&gt;

&lt;p&gt;Everyone wants to build AI agents.&lt;/p&gt;

&lt;p&gt;And when builders decide to give an AI agent access to data, many reach for the same default stack:&lt;/p&gt;

&lt;p&gt;Chunk documents, compute embeddings, store them in a vector database, and run cosine similarity search (RAG).&lt;/p&gt;

&lt;p&gt;For many tasks, like answering questions about documentation or searching blog posts, vector search works just fine.&lt;/p&gt;

&lt;p&gt;But the moment your problem depends on how things connect, vector search alone falls short.&lt;/p&gt;

&lt;p&gt;Let me show you why.&lt;/p&gt;

&lt;p&gt;The $15,000 OTC Dilemma&lt;/p&gt;

&lt;p&gt;Meet Dave.&lt;/p&gt;

&lt;p&gt;Dave runs an over-the-counter (OTC) crypto desk. He has Telegram open. A counterparty wants to buy $15,000 worth of stablecoins.&lt;/p&gt;

&lt;p&gt;The trade window has a timer: Dave has 2 minutes to accept or decline the quote.&lt;/p&gt;

&lt;p&gt;The counterparty drops a wallet address:&lt;/p&gt;

&lt;p&gt;0x7a250d5630b4cf539739df2c5dacb4c659f2488d&lt;/p&gt;

&lt;p&gt;Now Dave has a problem.&lt;/p&gt;

&lt;p&gt;If those funds are connected to an exploit, a money mule, or a sanctioned mixer such as Tornado Cash just a few hops away, the transaction could expose his business to serious compliance and financial risks.&lt;/p&gt;

&lt;p&gt;Enterprise tools like Chainalysis and TRM Labs can be expensive, putting advanced blockchain analytics out of reach for some independent operators.&lt;/p&gt;

&lt;p&gt;So a builder says:&lt;/p&gt;

&lt;p&gt;"Hey, let's build an AI agent with vector search to audit crypto wallets!"&lt;/p&gt;

&lt;p&gt;And here's the fundamental flaw.&lt;/p&gt;

&lt;p&gt;Vector Search Cannot Express a Graph Hop&lt;/p&gt;

&lt;p&gt;A vector database stores numerical representations of semantic meaning in a high-dimensional space.&lt;/p&gt;

&lt;p&gt;It can tell you that the phrase "illicit money laundering" is conceptually similar to "Tornado Cash mixer."&lt;/p&gt;

&lt;p&gt;But semantic similarity alone cannot establish:&lt;/p&gt;

&lt;p&gt;Did Address A send 5 ETH to Mule B?&lt;/p&gt;

&lt;p&gt;Did Mule B retain a 0.5% fee and forward the rest to Consolidator C?&lt;/p&gt;

&lt;p&gt;Did Consolidator C fund this exact counterparty 45 minutes later?&lt;/p&gt;

&lt;p&gt;Did the trail terminate at a Binance hot wallet?&lt;/p&gt;

&lt;p&gt;These are questions about relationships, direction, transaction history, and graph topology.&lt;/p&gt;

&lt;p&gt;When an LLM investigates a wallet using only vector search, it sees retrieved information without necessarily seeing the connections between the entities.&lt;/p&gt;

&lt;p&gt;That creates a dangerous gap between finding relevant information and establishing an evidence-backed transaction path.&lt;/p&gt;

&lt;p&gt;In financial forensics:&lt;/p&gt;

&lt;p&gt;Vector search finds semantic similarities. Graph queries trace relationships.&lt;/p&gt;

&lt;p&gt;They solve different problems, and knowing when to use each matters.&lt;/p&gt;

&lt;p&gt;The Removal Test: Making FalkorDB Load-Bearing&lt;/p&gt;

&lt;p&gt;When I entered the Graph Hacks Hackathon, rule #3 caught my attention immediately:&lt;/p&gt;

&lt;p&gt;"The graph has to do real work. If the product still works once FalkorDB is taken out, the graph is decoration."&lt;/p&gt;

&lt;p&gt;That rule separated serious graph-based solutions from projects that merely used a graph database as a technical accessory.&lt;/p&gt;

&lt;p&gt;I wanted to build ClearPath so that FalkorDB was the load-bearing engine of the entire product.&lt;/p&gt;

&lt;p&gt;Remove FalkorDB, and ClearPath loses the graph traversal and relationship analysis that power its core verdicts.&lt;/p&gt;

&lt;p&gt;Here's what happens under the hood when Dave clicks Evaluate.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Directional Multi-Hop Traversal with Exponential Decay&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of asking an LLM to guess whether two wallets might be connected, ClearPath runs an OpenCypher query against FalkorDB Cloud.&lt;/p&gt;

&lt;p&gt;MATCH path = (source:Wallet)-[:TRANSFERRED*1..4]-&amp;gt;(target:Wallet {address: $targetAddress})&lt;br&gt;
WHERE source.entity_type IN ['mixer', 'sanctioned', 'mule']&lt;br&gt;
  AND ALL(rel IN relationships(path) WHERE rel.amount_usd &amp;gt;= 10.0)&lt;br&gt;
  AND NONE(node IN nodes(path)[1..-1] WHERE node.entity_type = 'exchange_hot_wallet')&lt;br&gt;
RETURN&lt;br&gt;
  source.address AS source_address,&lt;br&gt;
  source.entity_type AS source_type,&lt;br&gt;
  length(path) AS hop_count,&lt;br&gt;
  [r IN relationships(path) | {&lt;br&gt;
    from: startNode(r).address,&lt;br&gt;
    to: endNode(r).address,&lt;br&gt;
    amount: r.amount_usd,&lt;br&gt;
    tx: r.tx_hash&lt;br&gt;
  }] AS steps&lt;/p&gt;

&lt;p&gt;Notice what's happening here:&lt;/p&gt;

&lt;p&gt;Multi-hop traversal: The query searches paths of up to four transfer edges between a flagged source and the target wallet.&lt;/p&gt;

&lt;p&gt;Dust filtering: Transfers below $10 are excluded to help reduce noise and potential dust-attack false positives.&lt;/p&gt;

&lt;p&gt;Exchange boundaries: Paths containing an exchange hot wallet as an intermediate node are excluded because centralized exchanges complicate direct on-chain attribution.&lt;/p&gt;

&lt;p&gt;Distance-based scoring: ClearPath applies exponential decay using a factor of (0.6^{\text{hop}}), so the contribution of a flagged source decreases as the number of hops increases.&lt;/p&gt;

&lt;p&gt;The key idea is that the system doesn't merely retrieve text about suspicious wallets. It traces actual relationships represented in the graph.&lt;/p&gt;

&lt;p&gt;FalkorDB is built around graph-processing techniques that leverage sparse matrix operations, making it well suited to relationship-heavy workloads.&lt;/p&gt;

&lt;p&gt;In my ClearPath implementation, the traversal returned results in 4 milliseconds during testing.&lt;/p&gt;

&lt;p&gt;That result is specific to my test environment and query; performance will vary with graph size, query complexity, and infrastructure.&lt;/p&gt;

&lt;p&gt;Still, it's a compelling demonstration of why graph databases deserve a place in the AI agent stack.&lt;/p&gt;

&lt;p&gt;Track 2: Giving the Agent True Episodic Memory&lt;/p&gt;

&lt;p&gt;Many projects describe their agents as having "memory" when they're simply appending chat transcripts to a database table.&lt;/p&gt;

&lt;p&gt;A chat log is useful, but it isn't the same as structured memory about what an agent previously investigated and what has changed since.&lt;/p&gt;

&lt;p&gt;In ClearPath, I used FalkorDB's multigraph capabilities to maintain separate graph contexts within the same cloud instance:&lt;/p&gt;

&lt;p&gt;clearpath_trust: The authoritative financial network.&lt;/p&gt;

&lt;p&gt;clearpath_mem_dave: Dave's private episodic memory graph.&lt;/p&gt;

&lt;p&gt;clearpath_shared_cases: A shared compliance board for verified fraud cases.&lt;/p&gt;

&lt;p&gt;When Dave investigates an address today that he scanned two hours ago, the agent can check for new transactions instead of starting from scratch.&lt;/p&gt;

&lt;p&gt;For example, it can run a temporal delta query:&lt;/p&gt;

&lt;p&gt;MATCH (inflow:Wallet)-[r:TRANSFERRED]-&amp;gt;(target:Wallet {address: $targetAddress})&lt;br&gt;
WHERE r.timestamp &amp;gt; $lastSessionTimestamp&lt;br&gt;
RETURN&lt;br&gt;
  count(r) AS new_inflows,&lt;br&gt;
  coalesce(sum(r.amount_usd), 0.0) AS new_volume&lt;/p&gt;

&lt;p&gt;If a new transaction occurred while Dave was away, the agent can surface an alert:&lt;/p&gt;

&lt;p&gt;"Notice: 1 new transaction ($8,500) detected since your last screening."&lt;/p&gt;

&lt;p&gt;That's the idea behind ClearPath's cross-session episodic memory: retain relevant investigative context and use it to identify changes over time.&lt;/p&gt;

&lt;p&gt;Of course, the quality of those alerts depends on accurate timestamps, complete transaction data, and correctly implemented session tracking.&lt;/p&gt;

&lt;p&gt;The "Theater Test"&lt;/p&gt;

&lt;p&gt;During hackathon demos, judges have good reason to be skeptical. They've seen plenty of mockups with hardcoded states that look impressive but don't demonstrate a working backend.&lt;/p&gt;

&lt;p&gt;So we built what I call the Theater Test.&lt;/p&gt;

&lt;p&gt;Here's how it works:&lt;/p&gt;

&lt;p&gt;Evaluate Exhibit C (0xDEMO_CLEAN_TARGET_03). The verdict comes back as NO-KNOWN-RISK.&lt;/p&gt;

&lt;p&gt;Click "Inject Mule Transfer (Flip to Caution)."&lt;/p&gt;

&lt;p&gt;Behind the scenes, an actual Cypher query executes against FalkorDB Cloud, creating a transfer edge from a known demo money-mule entity into Exhibit C.&lt;/p&gt;

&lt;p&gt;Run the evaluation again. The screen changes to CAUTION, the visual transaction trail displays the new connection, and the temporal-delta banner appears.&lt;/p&gt;

&lt;p&gt;Click "Rollback Taint." The newly created edge is deleted, and the screen returns to its previous state after re-evaluation.&lt;/p&gt;

&lt;p&gt;The point isn't simply that the UI changes.&lt;/p&gt;

&lt;p&gt;It's that the change is driven by a mutation to the underlying graph, followed by a fresh evaluation.&lt;/p&gt;

&lt;p&gt;Hardcoded demos show a state. Live graph systems can demonstrate how that state changes when the underlying relationships change.&lt;/p&gt;

&lt;p&gt;That distinction matters when you're building products that claim to reason over real data.&lt;/p&gt;

&lt;p&gt;What I Took Away From This&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Problem first, technology last&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The goal was never to show off a graph database or an AI model for its own sake.&lt;/p&gt;

&lt;p&gt;The goal was to help Dave make a better-informed decision during a two-minute deal window.&lt;/p&gt;

&lt;p&gt;Every technical choice should serve that problem.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deterministic computation beats generative guessing&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One of the biggest mistakes in AI agent design is allowing an LLM to invent or independently calculate critical risk scores without a deterministic, auditable method.&lt;/p&gt;

&lt;p&gt;In ClearPath, FalkorDB handles relationship traversal, while the scoring logic applies explicit rules. Google Gemini 2.5 Flash is used to explain the evidence in human-readable language.&lt;/p&gt;

&lt;p&gt;The distinction is important:&lt;/p&gt;

&lt;p&gt;Let deterministic systems calculate the evidence-based result. Let the LLM explain it.&lt;/p&gt;

&lt;p&gt;Neither a graph connection nor an automated risk score, however, should automatically be treated as proof of wrongdoing. Real financial investigations require reliable data, context, and appropriate human review.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Graph databases are more than a visualization layer&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;FalkorDB isn't there just to draw pretty lines between wallets.&lt;/p&gt;

&lt;p&gt;It's part of the computation that makes ClearPath work: traversing transaction paths, identifying relationships, and detecting changes in the network.&lt;/p&gt;

&lt;p&gt;That makes the graph load-bearing rather than decorative.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make demos prove the architecture&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A convincing demo shouldn't just show what a product looks like when everything works.&lt;/p&gt;

&lt;p&gt;It should demonstrate what happens when the underlying data changes, how the system responds, and whether the result can be reproduced.&lt;/p&gt;

&lt;p&gt;That's why the Theater Test mattered to me.&lt;/p&gt;

&lt;p&gt;Final Thoughts&lt;/p&gt;

&lt;p&gt;If you're building AI agents and your problem involves relationships, hierarchies, dependencies, or networks, don't force vector search to do a graph database's job.&lt;/p&gt;

&lt;p&gt;Vector search is useful for semantic retrieval. Graph databases are useful for traversing and analyzing relationships. In many real-world systems, combining them is more powerful than treating either as a universal solution.&lt;/p&gt;

&lt;p&gt;Give your agent the right tools for the problem.&lt;/p&gt;

&lt;p&gt;For ClearPath, that meant making the graph do real work.&lt;/p&gt;

&lt;p&gt;Built by Khalid for Graph Hacks 2026.&lt;/p&gt;

&lt;p&gt;🔗 Explore my work: &lt;a href="https://github.com/theweb3wizard" rel="noopener noreferrer"&gt;https://github.com/theweb3wizard&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
