STOCKBALLER

Web3 Sports Trading Platform with Chainlink Oracles
Built with React Native, NestJS, Prisma/MongoDB & Solidity
Tokenized Athletes • 100+ Trading Bots • AI-Powered Predictions

Scroll

STOCKBALLER - WEB3 SPORTS TRADING

Project Type

Full-Stack Web3 Development • Mobile Application • Smart Contracts

Tech Stack
React Native Expo NestJS Prisma MongoDB Solidity Hardhat Chainlink Base Sepolia ethers.js GPT-4
Project Date March 2026
Role Full-Stack Development • Smart Contracts • DevOps
Client Stockballer / Digital Villains

Executive Summary

StockBaller is a full-stack Web3 sports trading platform built with React Native (Expo), NestJS, Prisma/MongoDB, and Solidity smart contracts—enabling users to buy/sell tokenized athlete shares with prices driven by real match statistics. The integration of Chainlink CRE workflows for decentralized price oracles and GPT-4 for AI-powered match predictions delivers a trustless, transparent trading experience that eliminates single points of failure while supporting 100+ automated trading bots and seamless on-chain settlement on Base Sepolia.

100+ Automated Trading Bots
1,000+ Trades Per Hour
<100ms API Response Time
3 Platforms (iOS/Android/Web)

Chainlink CRE Oracle Integration Demo

The Architectural Challenge

The Core Problem: Real-Time Data Integrity at Scale

Building a sports trading platform presented three critical engineering challenges:

1. Trustless Price Feeds

Traditional sports apps rely on centralized backends to update prices, creating manipulation risk and single points of failure. Users had no way to verify that athlete token prices reflected actual match performance.

2. Complex Multi-Chain State Management

Synchronizing state between a MongoDB database, ERC-1155 smart contracts, and real-time API data (API-Football) required careful orchestration to prevent race conditions and ensure atomic transactions.

3. Scalable Bot Fleet Simulation

Testing market dynamics required simulating 100+ trading bots with distinct strategies (Value Investor, Day Trader, Momentum, Random) executing concurrent trades without overwhelming the system.

4. AI Prediction Settlement

GPT-4 match predictions needed to be submitted on-chain with cryptographic proof, then settled against actual results with verifiable payouts.

Key Engineering Decisions

Backend: NestJS + Prisma + MongoDB

Why NestJS? The modular architecture with dependency injection made it ideal for separating concerns across 10+ feature modules (market, trading, prediction, blockchain, bots, scheduler). Built-in support for Swagger documentation, guards, and interceptors accelerated API development.

Why Prisma + MongoDB? The schema-first approach with Prisma provided type-safe database queries while MongoDB's document model handled flexible JSON fields (player stats, yield data) without rigid migrations. The @unique constraints on tokenId and walletAddress ensured data integrity across the trading system.

model PlayerAsset { tokenId Int @unique // Maps to ERC-1155 Token ID stats Json // Flexible: { "goals": 20, "assists": 5 } yieldData Json // { "yield_per_share": 5.50, "apy": "8.3%" } }
Frontend: React Native (Expo) + Web3

Why Expo? A single codebase deployed to iOS, Android, and Web (stockballer.app). Expo Router provided file-based routing matching the app/ directory structure, while NativeWind (TailwindCSS for React Native) enabled consistent styling via global.css.

Why ethers.js for Web3? Direct integration with MetaMask and WalletConnect, with typed contract ABIs generated from Hardhat compilation. The WalletStore (Zustand) managed wallet state across the app.

Blockchain: Base Sepolia + ERC-1155

Why Base Sepolia? Low gas fees, fast finality, and EVM compatibility made it ideal for high-frequency trading simulation. Base's Coinbase backing provided reliable testnet infrastructure.

Why ERC-1155? Multi-token standard allowed each athlete to have a unique tokenId within a single ProSpectVault.sol contract—reducing deployment costs versus individual ERC-20 tokens per player.

Oracle Layer: Chainlink CRE Workflow

Why Chainlink CRE (Compute Runtime Environment)? The decentralized oracle network eliminated trust requirements:

  • HTTP Fetch → CRE workflow pulls stats from API-Football
  • Price Calculation → Multiple nodes compute prices using the StockBaller formula
  • BFT Consensus → Byzantine Fault Tolerant aggregation verifies results
  • EVM Write → Verified price written to ProSpectVaultV2.sol

This architecture ensures no single party can manipulate athlete prices.

Technical Deep-Dive

1. Custom Pricing Formula Engine

The proprietary pricing algorithm balances performance rewards with risk penalties:

// Pricing Formula (priceCalculator.ts) Price = (Base_Yield - Penalties) × Form_Multiplier × Age_Multiplier // Yield Factors Positive_Yield = (Goals × $0.25) + (Assists × $0.12) + (Matches × $0.02) Penalties = (Yellow × $0.05) + (Red × $0.50) + (Penalty_Miss × $0.15) // Age Multipliers Under 20 → 15x (high growth potential) 20-27 → 12x (prime years) Over 27 → 8x (experience premium) // Bounds: $5.00 floor, $100.00 ceiling

2. Bot Trading System Architecture

The automated trading system uses a strategy pattern with pluggable algorithms:

Strategy Behavior
VALUE_INVESTOR Buys undervalued young players (age < 20), holds long-term
DAY_TRADER High-frequency trading, targets small profits per trade
MOMENTUM Follows hot performers, trend-based entry/exit
RANDOM Random trades for market noise simulation
Blockchain Mode Toggle:
BLOCKCHAIN_TRADING_ENABLED=false # Simulated (database only) BLOCKCHAIN_TRADING_ENABLED=true # Live on-chain transactions

3. AI Prediction Oracle Pattern

GPT-4 predictions are submitted on-chain for verifiable settlement:

API-Football
(Fixtures)
GPT-4 Analysis
(Score + %)
PredictionMarket
.submitPrediction()
On-Chain Settlement
matchId, homeScore, awayScore, timestamp → txHash

4. Smart Contract Architecture

ProSpectVault.sol (ERC-1155)
  • Fixed supply: 1,000 tokens per athlete
  • Trading fee: 0.5% (50 basis points)
  • Oracle authorization: Only Chainlink workflow can update prices
PredictionMarket.sol
  • Stores AI predictions with cryptographic timestamps
  • Settles bets against actual match results
  • Auto-distributes £100 bonus to winners

Measurable Results

Performance Metrics

Metric Result
API Response Time < 100ms average (NestJS + Prisma query optimization)
Bot Fleet Scale 500+ concurrent bots with distinct wallets
Transaction Throughput 1,000+ simulated trades/hour in stress tests
Cross-Platform Deploy Single codebase → iOS, Android, Web

Code Quality

Metric Result
E2E Test Coverage Blockchain, trading, market, scheduler modules
Type Safety 100% TypeScript (API, frontend, Chainlink workflow)
Contract Tests Hardhat test suite with coverage reporting

Blockchain Integration

Metric Result
Contracts Deployed 3 (ProSpectVaultV2, PredictionMarket, MockUSDC)
Network Base Sepolia (Chain ID: 84532)
Oracle Type Chainlink CRE with BFT consensus

Market Simulation Results

From the V2 simulation report (25 players analyzed):

Scenario Avg Price Change Market Cap Growth
Maintain Form +38.4% $684K → $947K
Improved (+20%) +41.4% $684K → $967K
Declined (-30%) +32.6% $684K → $907K

Top Performer: E. Smith Rowe at +1,900% projected growth (youth multiplier + form).

Deployment Architecture

FRONTEND
React Native (Expo) | iOS | Android | Web
stockballer.app
BACKEND API
NestJS | Prisma | MongoDB | Docker
Port 3001 | Swagger at /api/docs
PRICE ORACLE LAYER
Chainlink CRE | BFT Consensus | API-Football
SMART CONTRACTS
ProSpectVaultV2 | PredictionMarket | MockUSDC
Base Sepolia (Chain ID: 84532)

Technology Stack

Frontend
  • Framework: React Native (Expo)
  • Routing: Expo Router (file-based)
  • Styling: NativeWind (TailwindCSS)
  • State Management: Zustand
  • Web3: ethers.js + WalletConnect
  • Platforms: iOS, Android, Web
Backend
  • Framework: NestJS (Node.js 20)
  • ORM: Prisma
  • Database: MongoDB Atlas
  • API Docs: Swagger/OpenAPI
  • Container: Docker
  • External Data: API-Football
Blockchain
  • Network: Base Sepolia (Chain ID 84532)
  • Smart Contracts: Solidity 0.8.x
  • Development: Hardhat
  • Token Standard: ERC-1155
  • Oracle: Chainlink CRE
  • Testing: Hardhat + Chai
AI & Automation
  • AI Model: GPT-4 (OpenAI)
  • Bot System: 500+ concurrent traders
  • Strategies: Value, Day Trading, Momentum, Random
  • Scheduler: NestJS @nestjs/schedule

Key Takeaways

1. Chainlink CRE enables trustless sports data

Decentralized price oracles eliminate manipulation risk without sacrificing real-time updates.

2. ERC-1155 is optimal for multi-asset trading

Single contract deployment with unique token IDs per athlete reduces gas costs and simplifies frontend integration.

3. NestJS modular architecture scales

Separating trading, prediction, blockchain, and bot modules allowed parallel development and isolated testing.

4. AI + On-Chain creates verifiable predictions

GPT-4 analysis with cryptographic settlement provides transparency that centralized sports betting cannot match.

5. Expo enables true cross-platform Web3

A single TypeScript codebase deployed to iOS, Android, and Web with consistent wallet connectivity.

Conclusion

StockBaller demonstrates cutting-edge Web3 engineering, combining decentralized oracle networks, AI-powered predictions, and mobile-first design into a trustless sports trading platform. By leveraging Chainlink CRE for price integrity, ERC-1155 for efficient multi-token management, and NestJS for scalable backend architecture, the platform achieves production-ready performance with 500+ concurrent bots and sub-100ms API response times. The cross-platform deployment via Expo and typed smart contract integration showcases modern full-stack blockchain development patterns.

Built for: B2B Sports Data — DeFi & Tokenization | CRE & AI | Prediction Markets

Live Platform: stockballer.app

Technologies: React Native, NestJS, Prisma, MongoDB, Solidity, Hardhat, Chainlink, Base Sepolia, GPT-4