Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

SoraOracle/SoraOracle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

336 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Sora Oracle Banner

Sora Oracle SDK v5.0

Production-ready permissionless oracle SDK with HTTP 402 micropayments on BNB Chain

License: MIT Solidity BNB Chain npm

🌐 Website β€’ 𝕏 Twitter β€’ πŸ“– Docs β€’ πŸ” Contract


πŸš€ Live on BNB Chain Mainnet

S402Facilitator Contract:
0x605c5c8d83152bd98ecAc9B77a845349DA3c48a3

βœ… Production Ready β€’ βœ… Verified on BSCScan β€’ βœ… Fully Functional


🎯 What is Sora Oracle?

Sora Oracle is a fully permissionless oracle SDK that lets you create prediction markets with trustless data feeds. No centralized oracles, no gatekeepers - just AI-powered API discovery, cryptographic verification, and s402 micropayments.

Key Features

βœ… Permissionless Oracle - AI discovers and verifies APIs automatically
βœ… s402 Micropayments - HTTP 402 payments using USDC on BNB Chain
βœ… Multi-Wallet Parallelization - 10x faster than sequential transactions
βœ… 23 Smart Contracts - Production-ready market types (binary, multi-outcome, AMM, orderbook, conditional)
βœ… TypeScript SDK - React hooks for zero-boilerplate integration
βœ… Mainnet Deployed - Live on BNB Chain


πŸš€ Quick Start

Install SDK

npm install @sora-oracle/sdk

Create Your First Market

import { SoraOracleSDK } from '@sora-oracle/sdk';

const sdk = new SoraOracleSDK({
  chainId: 56, // BNB Chain Mainnet
  rpcUrl: 'https://bsc-dataseed.binance.org/',
  s402FacilitatorAddress: '0x605c5c8d83152bd98ecAc9B77a845349DA3c48a3'
});

// Create a prediction market
const market = await sdk.createMarket({
  question: "Will BTC hit $100k by Dec 31, 2025?",
  type: "binary",
  deadline: "2025-12-31T23:59:59Z",
  payment: {
    token: "USDC",
    amount: "0.05" // $0.05 USDC payment
  }
});

console.log(`Market created: ${market.id}`);

πŸ“¦ Repository Structure

sora-oracle-sdk/
β”‚
β”œβ”€β”€ πŸ“„ README.md                              # You are here
β”œβ”€β”€ πŸ“„ QUICK_START.md                         # 5-minute guide
β”œβ”€β”€ πŸ“„ CONTRIBUTING.md                        # Contribution guide
β”œβ”€β”€ πŸ“„ LICENSE                                # MIT License
β”œβ”€β”€ πŸ“„ package.json                           # v5.0.0
β”‚
β”œβ”€β”€ πŸ“ contracts/                             # 23 Smart Contracts
β”‚   β”œβ”€β”€ S402Facilitator.sol                   # ⭐ s402 payment settlement (DEPLOYED)
β”‚   β”œβ”€β”€ SoraOracle.sol                        # Core oracle with bounties
β”‚   β”œβ”€β”€ SimplePredictionMarket.sol            # Binary (yes/no) markets
β”‚   β”œβ”€β”€ MultiOutcomeMarket.sol                # 2-10 outcome markets
β”‚   β”œβ”€β”€ OrderBookMarket.sol                   # Limit order book trading
β”‚   β”œβ”€β”€ AMMPredictionMarket.sol               # AMM-style liquidity pools
β”‚   β”œβ”€β”€ ConditionalMarket.sol                 # Markets with linked outcomes
β”‚   β”œβ”€β”€ RangeBettingMarket.sol                # Bet on price ranges
β”‚   β”œβ”€β”€ TimeSeriesMarket.sol                  # Statistical predictions
β”‚   β”œβ”€β”€ PancakeTWAPOracle.sol                 # Manipulation-resistant TWAP
β”‚   β”œβ”€β”€ BatchOracleOperations.sol             # Batch 20 questions (30% gas savings)
β”‚   β”œβ”€β”€ OracleReputationTracker.sol           # Provider performance tracking
β”‚   β”œβ”€β”€ DisputeResolution.sol                 # Stake-based challenges
β”‚   β”œβ”€β”€ AutomatedMarketResolver.sol           # AI-powered settlement
β”‚   β”œβ”€β”€ BatchPayoutDistributor.sol            # Efficient winner payouts
β”‚   β”œβ”€β”€ MarketFactory.sol                     # Market registry
β”‚   β”œβ”€β”€ ReferralRewards.sol                   # Viral growth (5% rewards)
β”‚   β”œβ”€β”€ LiquidityIncentives.sol               # Bootstrap new markets
β”‚   β”œβ”€β”€ AggregatedOracle.sol                  # Multi-source consensus
β”‚   β”œβ”€β”€ ScheduledFeeds.sol                    # Automated updates
β”‚   β”œβ”€β”€ CrossChainBridge.sol                  # Multi-chain data
β”‚   β”œβ”€β”€ DAOGovernance.sol                     # Community voting
β”‚   β”œβ”€β”€ OracleStaking.sol                     # Reputation staking
β”‚   └── SlashingMechanism.sol                 # Penalty system
β”‚
β”œβ”€β”€ πŸ“ src/sdk/                               # TypeScript SDK
β”‚   β”œβ”€β”€ MultiWalletS402Pool.ts                # ⭐ 10x parallel speedup
β”‚   β”œβ”€β”€ S402Client.ts                         # s402 payment client
β”‚   β”œβ”€β”€ s402-config.ts                        # Mainnet configuration
β”‚   β”œβ”€β”€ SoraOracleClient.ts                   # Oracle interactions
β”‚   β”œβ”€β”€ PredictionMarketClient.ts             # Market interactions
β”‚   └── MultiOutcomeMarketClient.ts           # Multi-outcome markets
β”‚
β”œβ”€β”€ πŸ“ src/ai/                                # Permissionless Oracle
β”‚   β”œβ”€β”€ SelfExpandingResearchAgent.ts         # ⭐ AI-powered API discovery
β”‚   β”œβ”€β”€ APIDiscoveryAgent.ts                  # Automatic API finding
β”‚   β”œβ”€β”€ DataSourceRouter.ts                   # Intelligent routing
β”‚   β”œβ”€β”€ TLSVerifier.ts                        # Certificate verification
β”‚   └── IPFSClient.ts                         # Decentralized storage
β”‚
β”œβ”€β”€ πŸ“ server/                                # Backend Examples
β”‚   β”œβ”€β”€ s402-middleware.js                    # ⭐ Payment verification
β”‚   β”œβ”€β”€ index.js                              # Blockchain indexer
β”‚   └── storage.ts                            # Database layer
β”‚
β”œβ”€β”€ πŸ“ frontend/                              # React UI Example
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/                       # React components
β”‚   β”‚   β”œβ”€β”€ pages/                            # App pages
β”‚   β”‚   β”œβ”€β”€ config.ts                         # Contract addresses
β”‚   β”‚   └── App.tsx                           # Main app
β”‚   └── package.json
β”‚
β”œβ”€β”€ πŸ“ scripts/                               # Deployment & Utils
β”‚   β”œβ”€β”€ deploy-s402-mainnet.js                # ⭐ Mainnet deployment
β”‚   β”œβ”€β”€ ai-oracle-settler.js                  # AI-powered settlement
β”‚   β”œβ”€β”€ fund-workers.js                       # Fund worker wallets
β”‚   β”œβ”€β”€ check-worker-balances.js              # Monitor balances
β”‚   └── [15+ more utility scripts]
β”‚
β”œβ”€β”€ πŸ“ test/                                  # Test Suite
β”‚   β”œβ”€β”€ S402Facilitator.test.js
β”‚   β”œβ”€β”€ MultiOutcomeMarket.test.js
β”‚   └── [comprehensive test coverage]
β”‚
β”œβ”€β”€ πŸ“ examples/                              # SDK Usage Examples
β”‚   β”œβ”€β”€ sdk-usage.ts                          # Basic SDK usage
β”‚   β”œβ”€β”€ multi-wallet-demo.ts                  # Parallel payments
β”‚   └── self-expanding-demo.ts                # Permissionless oracle
β”‚
└── πŸ“ docs/                                  # Documentation
    β”œβ”€β”€ SORA_ORACLE_TECHNICAL_SPECIFICATION.md    # ⭐ Complete architecture
    β”œβ”€β”€ V5_PERMISSIONLESS_ORACLE_COMPLETE.md      # ⭐ Self-expanding agent
    β”œβ”€β”€ X402_VS_S402_COMPARISON.md                # ⭐ s402 protocol explained
    β”œβ”€β”€ USDC_USDT_BNB_CHAIN_IMPLEMENTATION.md     # s402 implementation
    β”œβ”€β”€ EIP_PAYMENT_STANDARDS_COMPARISON.md       # EIP-2612 vs EIP-3009
    └── EIP3009_LOOPHOLE_ANALYSIS.md              # Why EIP-3009 doesn't work

⭐ = Core v5.0 features


πŸ—οΈ Architecture

v5.0: s402 Micropayment Protocol

Sora Oracle v5.0 introduces s402 - a custom HTTP 402 micropayment system for BNB Chain:

User Signs Payment β†’ s402 Middleware Verifies β†’ API Responds β†’ Settlement On-Chain
     (EIP-2612)           (Payment Proof)          (Data)      (Multi-Wallet Pool)

Key Components:

  1. S402Facilitator.sol - Smart contract for payment settlement (1% platform fee)
  2. MultiWalletS402Pool - 10 worker wallets for parallel transactions (10x speedup)
  3. s402-middleware.js - Backend payment verification
  4. Permissionless Oracle - AI-powered API discovery and verification

Why s402 Instead of x402?

x402 (Coinbase):

  • βœ… Uses EIP-3009 (random nonces, true parallel)
  • ❌ Only works on Base, Ethereum (chains with native Circle USDC)
  • ❌ Doesn't work on BNB Chain (no EIP-3009 support)

s402 (Sora):

  • βœ… Uses EIP-2612 (works on BNB Chain)
  • βœ… Multi-wallet pool solves sequential nonce problem
  • βœ… Achieves 10x parallel speedup
  • βœ… Honest branding - we don't claim x402 compliance

Read Full Comparison β†’


πŸ’‘ Use Cases

1. Permissionless Data Markets

// AI automatically discovers and verifies APIs
const oracle = await sdk.createPermissionlessOracle({
  question: "What's the current BTC price?",
  sources: "auto", // AI discovers APIs
  consensus: "median",
  verification: "tls+sha256+ipfs"
});

// Oracle queries multiple sources, verifies cryptographically
const answer = await oracle.query();
console.log(`BTC: $${answer.value} (confidence: ${answer.confidence}%)`);

2. Prediction Markets with s402

// Users pay $0.05 USDC to create markets
const market = await sdk.createMarket({
  question: "Will Ethereum merge happen in Q3?",
  type: "binary",
  payment: { token: "USDC", amount: "0.05" }
});

// Oracle automatically resolves using verified data
await market.resolve(); // AI-powered settlement

3. Multi-Outcome Markets

// Create election markets
const election = await sdk.createMarket({
  question: "Who wins 2024 election?",
  type: "multi-outcome",
  outcomes: ["Candidate A", "Candidate B", "Candidate C"],
  payment: { token: "USDC", amount: "0.10" }
});

πŸ› οΈ Smart Contracts

23 Production-Ready Contracts

Core Oracle (v3):

  • SoraOracle - Question/answer oracle with bounties
  • PancakeTWAPOracle - Manipulation-resistant TWAP pricing

Market Types (v3-v4):

  • SimplePredictionMarket - Binary (yes/no) markets
  • MultiOutcomeMarket - 2-10 outcome markets
  • OrderBookMarket - Limit order book (institutional-grade)
  • AMMPredictionMarket - AMM-style liquidity pools
  • ConditionalMarket - Markets with linked outcomes
  • RangeBettingMarket - Bet on price ranges
  • TimeSeriesMarket - Statistical predictions

Automation (v4):

  • AutomatedMarketResolver - AI-powered settlement
  • AggregatedOracle - Multi-source consensus
  • ScheduledFeeds - Automated oracle updates
  • CrossChainBridge - Multi-chain oracle data

Operations:

  • BatchOracleOperations - Batch 20 questions (30% gas savings)
  • BatchPayoutDistributor - Efficient winner payouts
  • DisputeResolution - Stake-based challenges
  • OracleReputationTracker - Provider performance

Governance:

  • DAOGovernance - Community voting
  • OracleStaking - Reputation and rewards
  • SlashingMechanism - Penalty system

Growth:

  • ReferralRewards - Viral growth (5% fee sharing)
  • MarketFactory - Market registry with categories
  • LiquidityIncentives - Bootstrap new markets

v5.0 - s402 Payments:

  • S402Facilitator - Payment settlement with 1% platform fee (View on BSCScan)

πŸ“Š Pricing

s402 Operation Costs

Operation Price (USDC) Description
Data Source Access $0.03 Query permissionless oracle
Oracle Query $0.01 Single oracle question
Market Creation $0.05 Create prediction market
Market Resolution $0.10 Resolve market outcome
Batch Query $0.05 Multiple oracle queries
AI Resolution $0.15 GPT-4 powered settlement

Platform Fee: 1% of all transactions (adjustable by owner, max 10%)


πŸ”’ Security

Smart Contract Security

  • βœ… OpenZeppelin v5 - Battle-tested libraries
  • βœ… ReentrancyGuard - All withdrawal functions protected
  • βœ… Pausable - Emergency stop mechanism
  • βœ… Access Control - Role-based permissions
  • βœ… Input Validation - All user inputs sanitized

s402 Payment Security

  • βœ… EIP-712 Signatures - Cryptographically secure payment authorizations
  • βœ… Replay Prevention - Used payment tracking
  • βœ… Recipient Binding - Payments cryptographically bound to recipient (prevents front-running)
  • βœ… Deadline Enforcement - All payments have expiration times
  • βœ… Dual-Signature - EIP-2612 permit + EIP-712 authorization

View Contract on BSCScan β†’


🌊 Gas Costs (BNB Chain)

Operation Gas BNB (3 Gwei) USD ($600 BNB)
Create Binary Market ~200K ~0.0006 BNB ~$0.36
Create Multi-Outcome ~250K ~0.00075 BNB ~$0.45
Place Bet ~50K ~0.00015 BNB ~$0.09
Claim Winnings ~45K ~0.000135 BNB ~$0.08
s402 Payment Settlement ~180K ~0.00054 BNB ~$0.32
Batch Oracle Operations ~35K ea ~0.000105 BNB ~$0.06

Total Cost: ~$0.40 to create + settle a market with s402


πŸ”— Network Information

BNB Chain Mainnet

BNB Chain Testnet


πŸ“– Documentation

Core Concepts

Comparison & Analysis

Getting Started


πŸ§ͺ Development

Setup

# Install dependencies
npm install

# Compile contracts
npx hardhat compile

# Run tests
npx hardhat test

# Deploy to testnet
npx hardhat run scripts/deploy-s402.js --network bscTestnet

Frontend

cd frontend
npm install
npm run dev

Access at: http://localhost:5000


🀝 Contributing

We welcome contributions! This is open-source MIT licensed software.

# Fork and clone
git clone https://github.com/YOUR_USERNAME/sora-oracle-sdk

# Install and test
npm install && npx hardhat test

# Create feature branch
git checkout -b feature/amazing-feature

# Submit PR

See CONTRIBUTING.md for detailed guidelines.


πŸ“„ License

MIT License - See LICENSE for details.

Use it, fork it, modify it, sell it - whatever you want! All smart contracts are fully permissionless and open source.


🌟 Why Sora Oracle?

vs. Traditional Oracles (Chainlink, UMA)

Feature Sora Oracle Chainlink UMA
Permissionless βœ… Anyone can add data ❌ Whitelisted nodes ⚠️ Token voting
AI-Powered βœ… GPT-4 discovery ❌ Manual ❌ Manual
Micropayments βœ… s402 ($0.01-0.15) ❌ LINK tokens ❌ UMA bonds
Multi-Source βœ… Automatic consensus ⚠️ Node consensus ⚠️ Optimistic
BNB Chain βœ… Native support βœ… Supported ⚠️ Limited
Verification βœ… TLS+SHA256+IPFS ⚠️ Node reputation ⚠️ Economic game

vs. Prediction Market Platforms

Feature Sora Oracle Polymarket Augur
Chain BNB (low fees) Polygon Ethereum
Oracle Permissionless Centralized UMA Decentralized
Market Types 8 types Binary only Binary + Categorical
Payments s402 (USDC) Free ETH gas
Orderbook βœ… Limit orders βœ… Limit orders ❌ Shares only
Mainnet βœ… Live βœ… Live βœ… Live

πŸ’¬ Support & Community


Sora Oracle v5.0 - The first production-ready permissionless oracle with integrated micropayments πŸš€

βœ… Permissionless | βœ… AI-Powered | βœ… s402 Payments | βœ… BNB Chain | βœ… Mainnet Live

No gatekeepers. No permissions. Just secure, verifiable prediction markets.

Built by the community, for the community 🌐

Get Started β†’ β€’ View Contract β†’ β€’ Follow on 𝕏 β†’

About

Sora delivers Decentralized Data Integrity and Real-Time Outcome Resolution for prediction markets on BNB Chain. Build with confidence using our permissionless, open-source oracle SDK. CA: 0xabebed1684a789b3cf178db810f3cbb30cc14444

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors