A decentralized binary options platform for betting on APT/USD price movements with automated rounds, real-time price feeds, and instant payouts.
- Problem Statement
- Live Demo
- Technical Architecture
- Smart Contract Design
- Getting Started
- Environment Setup
- Deployment Guide
- API Documentation
- Contributing
- License
Traditional betting platforms suffer from:
- Centralized control and potential manipulation
- Lack of transparency in price feeds and settlement
- Slow payouts and complex withdrawal processes
- Limited accessibility to global markets
- High fees and hidden costs
Orion solves these problems by:
- β Decentralized betting on Aptos blockchain
- β Real-time price data from Pyth Network
- β Automated settlement with 1.8x instant payouts
- β Transparent smart contracts with public verification
- β 24/7 automated rounds with 60-second intervals
π Production URL: orion-eosin.vercel.app/
π± Features:
- Real-time APT/USD price chart
- Live betting rounds with countdown timers
- Instant claim system for winnings
- Past rounds history and analytics
- Mobile-responsive design
graph TB
subgraph "Frontend Layer"
A[Next.js 15.5.4 App]
B[React Components]
C[Tailwind CSS]
D[Wallet Integration]
end
subgraph "API Layer"
E[Next.js API Routes]
F[Keeper Services]
G[Price Feed API]
end
subgraph "Blockchain Layer"
H[Aptos Testnet]
I[Smart Contracts]
J[Pyth Network]
end
subgraph "External Services"
K[Vercel Deployment]
L[Environment Variables]
end
A --> E
B --> D
E --> F
E --> G
F --> H
G --> J
H --> I
K --> L
| Component | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 15.5.4, React 19, TypeScript | User interface and wallet integration |
| Styling | Tailwind CSS 4, Lucide Icons | Modern, responsive design |
| State Management | Zustand | Global application state |
| Blockchain | Aptos SDK, Move Language | Smart contract interactions |
| Price Feeds | Pyth Network | Real-time APT/USD price data |
| Deployment | Vercel | Production hosting and CI/CD |
| Charts | Lightweight Charts | Price visualization |
The smart contract is built using the Move language and follows Aptos best practices for security and efficiency.
module orion_betting::betting {
// Core Functions
public entry fun init(admin: &signer, fee_bps: u64, treasury: address)
public entry fun start_round(admin: &signer, start_price: u64, duration_secs: u64)
public entry fun place_bet(user: &signer, admin_addr: address, round_id: u64, side_up: bool, amount: u64)
public entry fun settle(admin: &signer, round_id: u64, end_price: u64)
public entry fun claim(admin: &signer, round_id: u64, user_addr: address)
public entry fun batch_claim(admin: &signer, round_id: u64, user_addresses: vector<address>)
// View Functions
public fun get_current_round_id(admin_addr: address): u64
public fun get_round(admin_addr: address, round_id: u64): Round
public fun get_user_bet(admin_addr: address, round_id: u64, user_addr: address): UserBet
public fun calculate_potential_payout(admin_addr: address, round_id: u64, user_addr: address): u64
}struct State has key {
admin: address,
current_id: u64,
rounds: Table<u64, Round>,
fee_bps: u64,
treasury: address,
}
struct Round has store {
id: u64,
start_price: u64, // Price in micro-dollars (6 decimals)
end_price: u64,
expiry_time_secs: u64,
settled: bool,
up_pool: u64,
down_pool: u64,
user_bets: Table<address, UserBet>,
}
struct UserBet has store {
side_up: bool, // true = UP, false = DOWN
amount: u64, // Bet amount in octas (8 decimals)
claimed: bool,
}- 1.8x Payout System: Winners receive 1.8x their bet amount {this ensures protocols concurrent revenue stream}
- Pool-Based Betting: All bets go into UP/DOWN pools
- Automated Settlement: Smart contract handles round settlement
- Batch Claims: Efficient claiming for multiple users
- Treasury Management: Lost bets go to treasury address
- Event System: Comprehensive event logging for transparency
- Time-Based Validation: Rounds expire automatically
- Amount Validation: Minimum bet amounts enforced
- State Consistency: Atomic operations prevent race conditions
- Error Handling: Comprehensive error codes and messages
- Node.js 18+ and npm/yarn
- Aptos CLI for smart contract deployment
- Petra Wallet or compatible Aptos wallet
- Git for version control
- Clone the repository
git clone https://github.com/your-username/orion-betting.git
cd orion-betting- Install dependencies
npm install
# or
yarn install- Set up environment variables
cp .env.example .env.local-
Configure your environment (see Environment Setup)
-
Start development server
npm run dev
# or
yarn dev- Open your browser
Navigate to
http://localhost:3000
Create a .env.local file with the following variables:
# Aptos Network Configuration
NEXT_PUBLIC_APTOS_NETWORK=testnet
NEXT_PUBLIC_APTOS_NODE_URL=https://api.testnet.aptoslabs.com/v1
NEXT_PUBLIC_APTOS_API_KEY=your_aptos_api_key_here
NEXT_PUBLIC_MODULE_ADDRESS=your_deployed_contract_address
# Deployment Configuration
NEXT_PUBLIC_VERCEL_URL=your_vercel_deployment_url
# Price Feed Configuration
NEXT_PUBLIC_PYTH_ENDPOINT=https://hermes.pyth.network
NEXT_PUBLIC_PYTH_APT_USD_PRICE_ID=0x03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5
# Keeper Configuration (for automated rounds)
KEEPER_PRIVATE_KEY=ed25519-priv-0x_your_private_key_here
ROUND_DURATION_SECONDS=60
# Additional API Keys
GEOMI_API_KEY=your_geomi_api_key_hereHere's a working example from our current setup:
NEXT_PUBLIC_APTOS_NETWORK=testnet
NEXT_PUBLIC_APTOS_NODE_URL=https://api.testnet.aptoslabs.com/v1
NEXT_PUBLIC_APTOS_API_KEY=your_geomi_api_key
NEXT_PUBLIC_MODULE_ADDRESS=0x521ede792ad5eee5aece4e9e14bdf3c931f5e8d54939efc39b38afd7dd872cea
NEXT_PUBLIC_VERCEL_URL=orion-4dviyhaso-himanshuranjan007s-projects.vercel.app
NEXT_PUBLIC_PYTH_ENDPOINT=https://hermes.pyth.network
NEXT_PUBLIC_PYTH_APT_USD_PRICE_ID=0x03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5
KEEPER_PRIVATE_KEY=your_private_key
ROUND_DURATION_SECONDS=60
GEOMI_API_KEY=your_geomi_api_key_secret_here- Install Aptos CLI
curl -fsSL "https://aptos.dev/scripts/install_cli.py" | python3- Initialize Aptos project
aptos init --network testnet- Deploy the contract
cd move
aptos move publish --named-addresses orion_betting=0x521ede792ad5eee5aece4e9e14bdf3c931f5e8d54939efc39b38afd7dd872cea- Initialize the contract
aptos move run --function-id 0x521ede792ad5eee5aece4e9e14bdf3c931f5e8d54939efc39b38afd7dd872cea::betting::init --args u64:100 address:0x521ede792ad5eee5aece4e9e14bdf3c931f5e8d54939efc39b38afd7dd872cea- Build the application
npm run build- Deploy to Vercel
npx vercel --prod- Configure environment variables in Vercel dashboard
| Endpoint | Method | Description |
|---|---|---|
/api/keeper/start |
POST | Start the first betting round |
/api/keeper/settle |
POST | Settle current round and start next |
/api/keeper/auto-manage |
POST | Automatically manage rounds |
| Endpoint | Method | Description |
|---|---|---|
/api/contract/init |
POST | Initialize the betting contract |
/api/contract/start-round |
POST | Start a new betting round |
| Endpoint | Method | Description |
|---|---|---|
/api/claim |
POST | Claim user winnings |
/api/check-winnings |
POST | Check if user has winnings |
/api/price |
GET | Get current APT/USD price |
// Start a new round
const response = await fetch('/api/keeper/start', {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
// Check user winnings
const winnings = await fetch('/api/check-winnings', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
roundId: 1,
userAddress: '0x...'
})
});orion/
βββ src/
β βββ app/ # Next.js app router
β β βββ api/ # API routes
β β βββ landing/ # Landing page
β β βββ page.tsx # Main trading page
β βββ components/ # React components
β β βββ BettingPanel.tsx # Main betting interface
β β βββ TradingChart.tsx # Price chart component
β β βββ ClaimableRewards.tsx # Rewards management
β β βββ ui/ # Reusable UI components
β βββ lib/ # Utility libraries
β β βββ aptos.ts # Aptos SDK integration
β β βββ config.ts # Configuration management
β β βββ utils.ts # Helper functions
β βββ store/ # State management
β βββ betting.ts # Zustand store
βββ move/ # Smart contracts
β βββ sources/
β β βββ betting.move # Main betting contract
β βββ Move.toml # Move package configuration
βββ public/ # Static assets
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint{
"dependencies": {
"react": "19.1.0",
"next": "15.5.4",
"@aptos-labs/ts-sdk": "^1.28.0",
"@aptos-labs/wallet-adapter-react": "^3.7.1",
"zustand": "^5.0.1",
"lightweight-charts": "^4.2.0",
"lucide-react": "^0.460.0"
}
}We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature- Make your changes
- Add tests if applicable
- Commit your changes
git commit -m 'Add amazing feature'- Push to the branch
git push origin feature/amazing-feature- Open a Pull Request
- Follow TypeScript best practices
- Use meaningful commit messages
- Add JSDoc comments for functions
- Test your changes thoroughly
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- Aptos Labs for the blockchain infrastructure
- Pyth Network for real-time price feeds
- Vercel for deployment platform
- Next.js Team for the amazing framework
- Move Language for secure smart contracts
- Documentation: GitHub Wiki
- Issues: GitHub Issues
- Discord: Join our community
- Twitter: @OrionBetting
Built with β€οΈ by the Orion Team
Empowering decentralized betting on Aptos blockchain