A Decentralized Racing Game Powered by RedStone Pull Oracles
Race crypto assets in real-time using live price movements. Each player selects a cryptocurrency (ETH, BTC, SOL, etc.) and competes to see whose asset performs best during the race duration.
Oracle Racer is a multiplayer on-chain racing game where:
- Players race crypto assets, not traditional cars
- Each race lasts 30-300 seconds
- Winners are determined by real-time price performance
- Prices are fetched using RedStone Pull Oracles (only 2 reads per race)
- Automatic race start when full
- Points-based leaderboard system
Each cryptocurrency asset is represented as a racing car on the track. Here are all the available cars you can race with:
The game supports 8 different cryptocurrency assets, each with its own unique logo displayed as racing cars during races:
![]() ETH Ethereum |
![]() BTC Bitcoin |
![]() SOL Solana |
![]() AVAX Avalanche |
![]() LINK Chainlink |
![]() UNI Uniswap |
![]() AAVE Aave |
![]() ARB Arbitrum |
These asset logos are displayed as racing cars on the track, moving in real-time based on price performance. Each car represents a player's chosen cryptocurrency, and their position on the track reflects how well that asset is performing compared to others.
- Create & Join Races - Set duration (30-300s) and player count (2-8)
- Auto-Start - Race begins automatically when full
- Live Racing - Watch cars move in real-time based on price changes
- Dynamic Commentary - Real-time race updates in English
- Points System - Earn points based on race position (100, 70, 50, 35, 25, 15, 10, 5)
- Global Leaderboard - Compete for the top spot
- RedStone Pull Model - On-demand price fetching
- Minimal Gas Usage - Only 2 oracle reads per race
- Fresh Prices - Always up-to-date data from RedStone Gateway
- No On-Chain Storage - Prices read directly from transaction calldata
- Glassmorphism Design - Beautiful glass-effect cards
- Real-Time Updates - Live price feeds every second during races
- Responsive Layout - Works on desktop and mobile
- Smooth Animations - Cars move based on price performance
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ USER (Wallet) โ
โ createRace() / joinRace() โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FRONTEND (Next.js + Wagmi) โ
โ - Race list & creation โ
โ - Live race visualization โ
โ - Leaderboard & history โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ BACKEND RELAYER (Next.js API Routes) โ
โ - Auto-finish races โ
โ - Fetch RedStone price data โ
โ - Send transactions with oracle payload โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REDSTONE GATEWAY โ
โ - Signed price data packages โ
โ - 3+ independent signers โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ BASE SEPOLIA BLOCKCHAIN โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ OracleRacerSimple.sol โ โ
โ โ - Game logic โ โ
โ โ - Oracle Pull reads โ โ
โ โ - Scoring & winner โ โ
โ โ - Leaderboard โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
- Node.js 18+ and npm
- A wallet with Base Sepolia ETH for gas
- Git
-
Clone the repository
git clone <repository-url> cd oracle-racer-v2
-
Install dependencies
npm install
-
Configure environment variables
cp .env.example .env.local
Edit
.env.localwith your configuration:PRIVATE_KEY=your_relayer_private_key NEXT_PUBLIC_CONTRACT_ADDRESS=0x27DDfB306Fb37868ED865F84e69b8444A8A405E9 NEXT_PUBLIC_RPC_URL=https://base-sepolia.g.alchemy.com/v2/YOUR_API_KEY NEXT_PUBLIC_REDSTONE_GATEWAY_URL=https://oracle-gateway-1.a.redstone.finance NEXT_PUBLIC_REDSTONE_DATA_SERVICE=redstone-primary-prod NEXT_PUBLIC_REDSTONE_UNIQUE_SIGNERS=3 NEXT_PUBLIC_FALLBACK_RPC_URL=https://sepolia.base.org
-
Run development server
npm run dev
-
Open your browser
http://localhost:3000
-
Create Race
- Choose duration (30-300 seconds)
- Set player count (2-8)
- Select your asset (ETH, BTC, SOL, etc.)
- Race is created and you automatically join
-
Join Race
- Other players join with different assets
- Each asset can only be used once per race
- Race auto-starts when full
-
Race Active
- Watch cars move in real-time
- Positions update based on price performance
- Live commentary provides race updates
- Prices fetched every second for visualization
-
Race Finish
- Final prices recorded on-chain
- Winner determined by best price performance
- Points awarded to all participants
- Leaderboard updated
The winner is determined by the highest price percentage change:
score = (endPrice - startPrice) * 1e12 / startPricePoints Distribution:
- ๐ฅ 1st place: 100 points
- ๐ฅ 2nd place: 70 points
- ๐ฅ 3rd place: 50 points
- 4th: 35 points
- 5th: 25 points
- 6th: 15 points
- 7th: 10 points
- 8th: 5 points
Deployed on Base Sepolia: 0x27DDfB306Fb37868ED865F84e69b8444A8A405E9
Key Functions:
createRace(duration, maxPlayers, feedId)- Create and join a racejoinRace(raceId, feedId)- Join an existing racefinishRace(raceId)- Finish race and determine winner (requires RedStone payload)
Oracle Integration:
// Start prices (recorded when race auto-starts)
racer.startPrice = getOracleNumericValueFromTxMsg(racer.feedId);
// End prices (recorded when race finishes)
racer.endPrice = getOracleNumericValueFromTxMsg(racer.feedId);Only 2 Oracle Reads Per Race:
- When the last player joins โ race auto-starts โ start prices recorded
- When race finishes โ end prices recorded โ winner determined
npm run build- Push your code to GitHub
- Import project in Vercel
- Add environment variables in Vercel dashboard
- Deploy!
Required Environment Variables on Vercel:
PRIVATE_KEY- Relayer private key (for auto-finishing races)NEXT_PUBLIC_CONTRACT_ADDRESS- Deployed contract addressNEXT_PUBLIC_RPC_URL- Base Sepolia RPC endpointNEXT_PUBLIC_REDSTONE_GATEWAY_URL- RedStone Gateway URLNEXT_PUBLIC_REDSTONE_DATA_SERVICE- RedStone data service nameNEXT_PUBLIC_REDSTONE_UNIQUE_SIGNERS- Number of required signers
oracle-racer-v2/
โโโ contracts/
โ โโโ racer_game.sol # Main game contract
โโโ public/
โ โโโ images/ # Asset logos
โ โโโ eth.png
โ โโโ btc.png
โ โโโ sol.png
โ โโโ ...
โโโ src/
โ โโโ app/
โ โ โโโ api/
โ โ โ โโโ finish-race/ # Auto-finish race endpoint
โ โ โ โโโ prices/ # CoinGecko prices API
โ โ โ โโโ redstone-prices/ # RedStone prices API
โ โ โโโ layout.tsx
โ โ โโโ page.tsx
โ โโโ components/
โ โ โโโ RaceCard.tsx # Individual race display
โ โ โโโ RaceList.tsx # List of all races
โ โ โโโ CreateRace.tsx # Race creation form
โ โ โโโ Leaderboard.tsx # Global leaderboard
โ โ โโโ History.tsx # User race history
โ โ โโโ ...
โ โโโ config/
โ โ โโโ contract.ts # Contract ABI
โ โ โโโ wagmi.ts # Wagmi configuration
โ โโโ lib/
โ โโโ redstone.ts # RedStone integration
โโโ package.json
- โ RedStone Signature Verification - All prices are cryptographically signed
- โ Reentrancy Protection - Using OpenZeppelin's ReentrancyGuard
- โ Relayer Locking - Prevents concurrent race settlements
- โ Input Validation - All parameters validated on-chain
- โ Access Control - Owner-only functions protected
During active races, you'll see:
- Live race track with cars moving based on price performance
- Real-time prices updating every second
- Dynamic commentary providing race updates
- Timer showing time remaining
- Price changes displayed in real-time
Choose from 8 supported cryptocurrencies:
- Each asset has a unique logo and color
- Assets are displayed in a grid for easy selection
- Only available assets can be selected (no duplicates)
- Frontend: Next.js 15, React 19, TypeScript
- Styling: Tailwind CSS with custom glassmorphism theme
- Web3: Wagmi v2, Viem, Ethers.js
- Oracle: RedStone Pull Model
- Blockchain: Base Sepolia
- Deployment: Vercel
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License
- Contract Address (Base Sepolia): 0x27DDfB306Fb37868ED865F84e69b8444A8A405E9
- RedStone Documentation: docs.redstone.finance
- Base Sepolia Explorer: sepolia.basescan.org
- RedStone Finance for the amazing oracle infrastructure
- Base for the fast and affordable L2
- OpenZeppelin for security best practices
Built with โค๏ธ using RedStone Pull Oracles
๐๏ธ Race on! ๐๏ธ







