All projects

Sub0

A non-custodial Autonomous AI Prediction trading platform.

Prediction Markets CRE & AI Privacy Tenderly Thirdweb

What it is

A total of 80,192 transactions executed by 4 autonomous trading agents built within the duration of this hackathon
and a total of 42,443 Confidential trades (buy, sell, bid/ask) executed on the Chainlink's forwarder (sepolia) between 1st - 8th March.
Trades: https://sepolia.etherscan.io/txsInternal?a=0xfc4def105b3288e41f0ae8818bdd48d58f950772&m=advanced
Sub0: https://sepolia.etherscan.io/txsInternal?a=0xf5cdcaf95bb27fb43919d1c664a2618c773330dd&m=advanced

Project Link: https://sub0-markets.vercel.app

The Elevator Pitch 
The question we asked ourselves is how does an autonomous agent sign a transaction securely without a centralized backend holding its private keys? Sub0 solves this by leveraging the Chainlink Runtime Environment. Sub0 is a non-custodial prediction market platform that bridges advanced Large Language Models (LLMs) with decentralized finance. It allows both human traders and autonomous AI agents to seamlessly create, analyze, and execute trades on future events with zero custody risk. 
With this project, we were able to prove autonomous agents can run forever like the blockchain by replacing the off chain server with CRE.

What problem it solves
Traditional AI trading bots require hot wallets stored in plaintext on centralized databases, creating a massive security vulnerability. Sub0 eliminates this vector entirely by leveraging the Chainlink Runtime Environment (CRE) as a Trusted Execution Environment.
When a Sub0 agent decides to execute a trade, the platform does not hold its private key. Instead, the agent's trading intent and risk parameters are routed into the CRE. Inside this secure, isolated enclave, the agent's private key is statelessly derived, used to cryptographically sign an EIP-712 trade intent, and immediately destroyed. This guarantees that neither the platform developers nor the underlying infrastructure providers can access or misappropriate agent funds.

Core Features 
Deploy Custom AI Agents: Configure your agent's soul, persona, skills, and trading methodology.
Autonomous Market Generation: LLMs automatically create relevant, real-world prediction markets based on current trends.
Gasless Execution: Relayer contracts execute trades on behalf of users and agents.
Live Agent Tracker: Monitor your agent's internal thought process, probability cross-checks, and win rate.
VNet Simulations: Time-travel and backtest your agent's strategy without spending real collateral.

How it works
Sub0 utilizes HTTP Confidential requests, to feed the AI agents with real-time context without compromising the security of the enclave.
The CRE establishes a secure, encrypted communication tunnel directly to our off-chain Node.js server and Edge Workers (which handle Retrieval-Augmented Generation). This ensures that sensitive agent configurations, proprietary trading methodologies, and live market data are transmitted into the enclave privately. The payload remains completely obfuscated from node operators and public mempools until the final trade intent is cryptographically signed and ready for on-chain settlement.

Automated Market Makers in prediction markets rely on the Logarithmic Market Scoring Rule (LMSR) to dynamically adjust odds based on supply and demand. However, executing this math purely on-chain is gas-intensive, and calculating it purely off-chain introduces trust assumptions.
Sub0 solves this by offloading the LMSR price discovery to the Chainlink Decentralized Oracle Network (DON) running within the CRE.

  • Multiple oracle nodes observe the current state of the market's YES/NO token reserves.
  • The nodes compute the exact LMSR price and calculate the required quote (including slippage) for the agent's desired trade size.
  • The DON comes to a cryptographic consensus on this quote and generates a unified signature.

Testing autonomous trading strategies with real collateral is dangerous. To provide a rigorous proving ground, Sub0 integrates Tenderly Virtual Private Testnets (VNet) directly into the CRE workflow.
Before an agent is deployed to the live network, the CRE can route its logic through a simulation layer. The CRE fetches a perfectly forked state of the live blockchain via Tenderly, executes the agent's trading logic against the simulated LMSR curve, and outputs the exact financial result. This allows users to backtest an agent's personality, skill, and methodology under real historical market conditions without risking a single cent of real USDC.

Deployed Contracts (view Internal transactions)
Sub0 (proxy): https://sepolia.etherscan.io/address/0xF5CdCaf95BB27FB43919d1c664a2618c773330dd uses Forwarder
PredictionVault: https://sepolia.etherscan.io/address/0xFC4DEF105b3288E41f0aE8818bDD48d58F950772 uses Forwarder
ConditionalTokensV2: https://sepolia.etherscan.io/address/0xff6F3af86bF0f010f1a72Ba9C6be7bf22162D330
Deployed TestERC20 as USDC: https://sepolia.etherscan.io/address/0xeF536e7Dc524566635Ae50E891BFC44d6619a1FF
PermissionManager: https://sepolia.etherscan.io/address/0x5EF1c8a947C46D366EFeB2b7142e42E9dB21394D
TokensManager: https://sepolia.etherscan.io/address/0xB0d0640F11D9517709267Cd4159Fd5C6AC84C910
Oracle: https://sepolia.etherscan.io/address/0x4fd81EfC19A5Af3E9eAd9c147e5E9cF3CF823DE2
Hub: https://sepolia.etherscan.io/address/0x1f8eCAB9EDD176AD32B523013F8192335b96A6c8
Vault (VaultV2): https://sepolia.etherscan.io/address/0x018Baf94BF57EF4b62C510A94c1C35fA1C786A7d
Sub0 (implementation): https://sepolia.etherscan.io/address/0xac06d9172a7A903Ca61ebd2b6c5a41dc5026Ec22

Tenderly
Sub0 Tenderly Private Testnet: https://dashboard.tenderly.co/explorer/vnet/ac5f8bb1-c3ec-462f-ab62-8f6aa9f57935
Sub0 Tenderly Private Testnet 2: https://dashboard.tenderly.co/explorer/vnet/3f540fba-bc21-466a-854a-a87708151615/transactions

How it Works

The architecture hinges on five core entities communicating securely to prevent front-running, ensure mathematical accuracy, and guarantee cryptographic custody.

 Backend ↔ LLMs ↔ RAG
The communication process begins entirely off-chain within our Node.js backend.

  • When an agent, such as mrkaleel, is triggered by its custom cron schedule, the backend initiates requests to our Edge Workers (RAG).
  • These workers diligently scrape live news, sentiment, and pricing data, which they then transmit back to the backend.
  • The backend constructs a prompt that encapsulates the agent’s strict persona and methodology, along with the live RAG data. This prompt is subsequently sent to our LLM Fleet, comprising Gemini, Grok, and OpenWebUI.
  • The LLM meticulously calculates the true probabilities and responds to the backend with a raw Trade Intent, such as “Buy 500 ‘NO’ tokens on Market X with a maximum slippage of 2%.”

Offchain Backend ➔ Chainlink CRE

Now that the backend possesses the AI’s intent, it must securely transmit this information to the secure enclave without exposing the strategy to the public mempool or node operators.

  • To achieve this, the backend sends an HTTP Confidential request directly into the Chainlink CRE.
  • This process establishes a secure, encrypted tunnel. The CRE receives the Trade Intent entirely privately, ensuring that the AI’s alpha cannot be stolen or manipulated before execution.

Chainlink CRE ↔ LMSR ↔ DON)
Before the agent can execute the trade, it must have accurate market information.

  • Within the CRE, the Chainlink DON takes over. It queries the current state of the market on the blockchain to determine the current reserves of YES and NO tokens.
  • The DON performs the LMSR (Logarithmic Market Scoring Rule) calculations locally to calculate the precise cost of the requested 500 NO tokens, taking into account dynamic slippage.
  • The oracle nodes reach a cryptographic consensus on this price. The DON generates a signed Market Quote, effectively locking in the calculations.

Non-Custodial Key Generation
This section addresses the custody issue. The CRE now possesses the DON’s signed Market Quote and the AI’s Trade Intent.

  • The CRE statelessly derives the specific AI agent’s private key using a master enclave secret.
  • The CRE compares the DON’s Market Quote against the AI’s maximum slippage rules. If the calculations are valid, the CRE uses the derived private key to generate an EIP-712 Intent Signature.
  • A crucial step is that the private key is immediately erased from the CRE’s memory. This results in a secure Dual-Signature Payload (DON Quote + Agent Intent).

Settlement vs. Simulation (Chainlink CRE ➔ Onchain System / Tenderly)
The CRE then sends the Dual-Signature Payload to the onchain system or Tenderly.

  • Depending on the agent’s current mode, the CRE routes this Dual-Signature payload to either a live execution (on-chain system) or a backtesting (Tenderly VNet) destination.
  • In the live execution mode, the CRE sends writeReport to our PredictionVault smart contract on Sepolia. The contract verifies both signatures. If valid, it withdraws USDC from the agent’s wallet, splits it using the Conditional Tokens (ERC-1155) contract, and deposits the exact outcome tokens back to the agent.
  • In the backtesting mode, if the agent is in simulation mode, the CRE intercepts the broadcast. Instead of sending it to the live network, it routes the HTTP payload to a Tenderly Virtual Private Testnet (VNet) RPC. Tenderly executes the trade against a perfectly forked state of the blockchain, returning the simulated financial results to the backend without risking real USDC.

Links

Created by

  • Kaleel
  • Patrick