DEV Community

vault vult
vault vult

Posted on

Building Sentinel AI: A Security-First AI Trading Agent for HSK Chain

The Problem: Blind AI Trading

In the recent HSK Chain Horizon Hackathon, developers were tasked with building AI agents for DeFi. But as a smart contract auditor, I saw a massive flaw in the standard approach: AI trading bots are blind to security.

They will happily execute a trade on a malicious contract if the API tells them to, draining user funds in the process.

The Solution: Sentinel AI

I built Sentinel AI, a security-first trading agent deployed on the HSK Mainnet. It acts as a gatekeeper. Before any swap is executed on HSKSwap, the agent queries the blockchain RPC to verify the target contract's bytecode.

If the address is fake or malicious, the trade is instantly blocked. If safe, the AI executes the trade and applies a strict -5% Stop-Loss framework.

🛠️ How I Built It (Tech Stack)

  • Backend / AI Agent: Python, Web3.py, Flask
  • Smart Contracts: Solidity (AuditRegistry deployed on HSK Mainnet)
  • Frontend: Custom HTML/CSS/JS Dashboard

⚙️ The Core Logic

Instead of relying on an LLM to make financial decisions, the agent uses a deterministic security check:

  1. It checks if the address is a valid EVM format.
  2. It calls web3.eth.get_code() to ensure it's a real contract and not a spoofed wallet.
  3. It logs the immutable audit proof to a custom Solidity contract on HSK Mainnet before execution.

🔗 Links

Building this taught me a lot about the intersection of AI and security. AI agents are the future of DeFi, but they must be built with strict security guardrails.

Top comments (0)