Skip to content

imthegoodboy/AI_Oracle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AI Oracle Network - Decentralized AI Intelligence for Blockchain

"Chainlink for AI" - A decentralized oracle network bringing real-time AI intelligence to blockchain smart contracts

๐ŸŒŸ What is AI Oracle Network?

AI Oracle Network is a revolutionary platform that bridges artificial intelligence and blockchain technology. We enable smart contracts to access powerful AI models (GPT, image recognition, sentiment analysis) in a trustless, verifiable, and cross-chain manner.

The Problem We Solve

  • โŒ Smart contracts can't run AI models (too expensive, too complex)
  • โŒ Centralized AI APIs create single points of failure
  • โŒ No way to verify AI outputs on-chain
  • โŒ Current solutions require trusting off-chain providers

Our Solution

โœ… Decentralized marketplace where AI providers and developers connect
โœ… Multi-node consensus ensures accuracy and prevents manipulation
โœ… Pay-per-use pricing - only pay for what you need
โœ… Built on Polygon for fast, low-cost transactions
โœ… Cross-chain compatible - works across multiple blockchains


๐Ÿš€ Key Features

For AI Providers

  • ๐Ÿ’ฐ Earn rewards for providing accurate AI inferences
  • ๐Ÿ”’ Stake tokens to build reputation
  • ๐Ÿ“ˆ Track performance with detailed analytics
  • ๐ŸŽฏ Automatic routing of requests to your models

For Developers

  • ๐Ÿ”Œ Simple API integration
  • โšก Lightning-fast inference responses
  • ๐Ÿ” Verified results through consensus
  • ๐Ÿ“Š Usage analytics and cost tracking

For DApps

  • ๐Ÿค– AI-powered DeFi - risk analysis, price predictions
  • ๐Ÿ–ผ๏ธ Dynamic NFTs - evolving based on AI responses
  • ๐ŸŽฎ Smart NPCs - AI-driven game characters
  • ๐Ÿ›ก๏ธ Identity verification - KYC via AI
  • ๐Ÿ“ฑ Content moderation - automated filtering

๐Ÿ—๏ธ How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Smart Contract โ”‚ โ† (1) Requests AI inference
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Oracle Router  โ”‚ โ† (2) Routes to providers
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  AI Provider Network    โ”‚ โ† (3) Multiple providers process
โ”‚  - Provider A: GPT-4    โ”‚
โ”‚  - Provider B: Vision   โ”‚
โ”‚  - Provider C: Audio    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Verification   โ”‚ โ† (4) Consensus check (2/3 must match)
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Result on-chainโ”‚ โ† (5) Verified result delivered
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Step-by-Step Process

  1. Developer requests AI inference via smart contract
  2. Payment locked in $ORACLE tokens
  3. Multiple providers assigned to process request
  4. AI models run off-chain computation
  5. Results compared - 2/3 consensus required
  6. Verified result posted on-chain
  7. Payment distributed to accurate providers

๐Ÿ’ผ Real-World Use Cases

Use Case Description Example
DeFi Intelligence AI-powered risk analysis and predictions Lending protocol adjusts rates based on AI risk scores
Dynamic NFTs NFTs that evolve using AI Character NFT gets new traits from AI generation
Prediction Markets AI-driven odds and analysis Sports betting with AI-analyzed probabilities
Gaming NPCs On-chain AI characters RPG merchant generates contextual dialogue
Content Moderation Decentralized social filtering DAO auto-flags spam using AI classification
Identity Verification KYC via facial recognition DeFi platform verifies users with AI liveness check
Automated Trading AI trading signals on-chain Contract executes trades based on AI sentiment
Supply Chain Computer vision quality checks Smart contract validates shipment via image AI

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React + TypeScript - Type-safe component architecture
  • Vite - Lightning-fast builds and HMR
  • Tailwind CSS - Utility-first styling with custom design system
  • shadcn/ui - Beautiful, accessible component library
  • TanStack Query - Server state management

Backend (Lovable Cloud)

  • PostgreSQL - Relational database for providers, models, requests
  • Row Level Security (RLS) - Database-level access control
  • Edge Functions - Serverless functions for business logic
  • Real-time Subscriptions - Live updates for inference results

Blockchain

  • Polygon Network - Fast, low-cost transactions
  • Solidity - Smart contract language
  • Web3.js / ethers.js - Blockchain interaction

๐Ÿ“Š Database Schema

Core Tables

profiles - User accounts

  • Links to authentication system
  • Stores user metadata

user_roles - Role-based access control

  • Separate from profiles for security
  • Roles: admin, provider, developer

ai_providers - Provider profiles

  • Provider name, description, website
  • Stake amount and reputation score
  • Total requests and success rate

ai_models - AI model catalog

  • Model type (text, image, audio, video, multimodal)
  • Pricing per inference
  • Performance metrics (response time, accuracy)

inference_requests - AI inference requests

  • Request data (JSONB for flexibility)
  • Status tracking (pending, processing, completed, failed, disputed)
  • Response data and processing time

transactions - Financial records

  • Payment tracking
  • Stake management
  • Reward distribution

๐Ÿ” Security Features

Row Level Security (RLS)

  • โœ… Users can only access their own data
  • โœ… Providers can only manage their own models
  • โœ… Admins have elevated permissions via has_role() function
  • โœ… Security definer functions prevent RLS recursion

Authentication

  • โœ… Email/password authentication
  • โœ… Auto-confirm emails (configurable)
  • โœ… Session management with automatic refresh
  • โœ… Protected routes require authentication

Input Validation

  • โœ… Client-side validation with Zod schemas
  • โœ… Server-side validation in edge functions
  • โœ… SQL injection prevention via parameterized queries
  • โœ… XSS protection through proper escaping

๐Ÿ’ฐ Pricing

Subscription Tiers

Tier Price Inferences/Month Features
Starter Free 100 Basic models, community support
Professional $99/mo 10,000 All models, priority support, analytics
Enterprise Custom Unlimited Dedicated models, SLA, custom pricing

Pay-as-you-go Pricing

  • Text Models: $0.01 - $0.10 per inference
  • Image Models: $0.05 - $0.50 per inference
  • LLM Queries: $0.10 - $1.00 per query
  • Custom Models: Contact for pricing

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Git

๐Ÿ“š API Documentation

Quick Start Example

import { AIOracle } from '@ai-oracle/sdk';

const oracle = new AIOracle(process.env.AI_ORACLE_API_KEY);

// Request AI inference
const result = await oracle.inference({
  model: 'gpt-4',
  prompt: 'Analyze this wallet address for risk factors',
  parameters: {
    temperature: 0.7,
    max_tokens: 1000
  }
});

console.log(result);
// {
//   id: "req_123456",
//   result: "This wallet shows low risk factors...",
//   processing_time: 1250,
//   cost: 0.15
// }

Smart Contract Integration

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";

contract AIOracle is ChainlinkClient {
    string public aiResult;
    
    function requestAIInference(string memory _prompt) public {
        // Request AI inference
        Chainlink.Request memory request = buildChainlinkRequest(
            jobId, 
            address(this), 
            this.fulfill.selector
        );
        request.add("prompt", _prompt);
        sendChainlinkRequest(request, fee);
    }
    
    function fulfill(bytes32 _requestId, string memory _result) 
        public 
        recordChainlinkFulfillment(_requestId) 
    {
        aiResult = _result;
    }
}

โšก Built on Polygon

AI Oracle Network is optimized for Polygon Network, providing:

  • โšก Sub-second block times
  • ๐Ÿ’ฐ Transaction costs under 1ยข
  • ๐Ÿ”’ Ethereum-grade security
  • ๐ŸŒ Carbon-neutral operations

AI Oracle Network - Where AI Meets Blockchain

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published