Architecture Overview
Loyalteez uses a distributed Cloudflare Worker architecture to provide seamless, gasless blockchain rewards.
System Architecture
Event Tracking Flow
Gasless Transaction Flow
Perk Claiming Flow
Payment & LTZ Minting Flow
OAuth Pregeneration Flow (Idempotent)
Component Breakdown
1. JavaScript SDK
Purpose: Capture user events and send to Event Handler
Key Features:
- Auto-detection of form submissions
- Email extraction
- Event deduplication
- Configurable event rules
Integration:
<script src="https://api.loyalteez.app/sdk.js"></script>
<script>
Loyalteez.init('YOUR_BRAND_ID');
</script>
2. Event Handler Worker
Purpose: Process events and distribute LTZ rewards
Endpoints:
POST /loyalteez-api/manual-event- Track eventsPOST /loyalteez-api/checkout- Stripe checkoutGET /loyalteez-api/debug- Health check
Key Functions:
- Event validation
- User wallet creation (via Privy)
- LTZ distribution
- Event logging
3. Gas Relayer Worker
Purpose: Enable gasless transactions for users
Endpoints:
POST /relay- Execute gasless transaction
Key Features:
- Privy authentication
- Contract whitelisting
- Rate limiting (35 tx/hour/user)
- EIP-2612 permit support
- Gas budget protection
4. Pregeneration Worker ✨ Production Ready
Purpose: Create wallets for users before they log in (OAuth pregeneration)
Domain: register.loyalteez.app
Endpoints:
POST /loyalteez-api/pregenerate-user- Pregenerate OAuth wallet
Key Features:
- Idempotent - Safe to call multiple times (returns existing wallet)
- Server-side Privy integration - No credentials needed from developers
- 8 OAuth providers supported - Discord, Twitter, GitHub, Google, Telegram, Spotify, Instagram, TikTok
- Real OAuth validation - Rejects test/fake credentials for security
- Deterministic - Same OAuth ID = same wallet (always)
- Supabase event logging - Full audit trail
created_newflag - Track new vs. existing users
Use Cases:
- Discord bots rewarding users before they log in
- Twitter engagement campaigns
- GitHub contribution rewards
- Multi-platform user onboarding
- Reward failsafe systems (idempotent by design)
Security:
- Requires valid
brand_id(controlled access) - Validates credentials with actual OAuth providers
- Rate limited (100 requests/min per brand)
- Server-side only (no frontend exposure)
Learn More: OAuth Pregeneration Guide | API Reference
Note: The Pregeneration Worker only creates/retrieves wallets - it does NOT send LTZ tokens. To send rewards, you need to either:
- Use the Event Handler API to create reward distributions
- Use your own LTZ transfer mechanism
- Use the Reward Processor (scheduled worker that processes pending rewards)
5. Stripe Mint Worker
Purpose: Convert fiat payments to LTZ credits
Key Functions:
- Stripe webhook handling
- Payment verification
- LTZ minting
- Balance updates
Security Model
Data Flow
Network Architecture
All Workers are deployed on Cloudflare's global edge network, providing:
- 🌍 Global Distribution - Low latency worldwide
- ⚡ Auto-scaling - Handles traffic spikes automatically
- 🔒 DDoS Protection - Built-in protection
- 📊 Analytics - Real-time metrics
Blockchain: Soneium Mainnet (Chain ID: 1868)
Database: Supabase (PostgreSQL with RLS)
Auth: Privy (Smart Account Wallets)
Key URLs
Mainnet (Production)
| Service | URL | Purpose |
|---|---|---|
| SDK | api.loyalteez.app/sdk.js | Event tracking |
| Event Handler | api.loyalteez.app/loyalteez-api/* | Backend API |
| Gas Relayer | relayer.loyalteez.app/relay | Gasless transactions |
| Pregeneration | register.loyalteez.app/loyalteez-api/pregenerate-user | OAuth wallet creation |
| Partner Portal | partners.loyalteez.app | Dashboard |
Testnet (Testing)
| Service | URL | Purpose |
|---|---|---|
| SDK | api.loyalteez.xyz/sdk.js | Event tracking (testnet) |
| Event Handler | api.loyalteez.xyz/loyalteez-api/* | Backend API (testnet) |
| Gas Relayer | relayer.loyalteez.xyz/relay | Gasless transactions (testnet) |
| Pregeneration | register.loyalteez.xyz/loyalteez-api/pregenerate-user | OAuth wallet creation (testnet) |
| Partner Portal | partners.loyalteez.xyz | Dashboard (testnet) |
📚 Learn More: See the Testnet Guide for complete testnet documentation.
Contract Addresses
Soneium Mainnet (Production)
| Contract | Address |
|---|---|
| Loyalteez Token | 0x5242b6DB88A72752ac5a54cFe6A7DB8244d743c9 |
| PerkNFT | 0x6ae30d6Dcf3e75456B6582b057f1Bf98A90F2CA0 |
| PointsSale | 0x5269B83F6A4E31bEdFDf5329DC052FBb661e3c72 |
Soneium Minato Testnet (Testing)
| Contract | Address |
|---|---|
| Loyalteez Token | 0x8C894048a1313Df870f293a6Db6E744B244F6cf0 |
| PerkNFT | 0x4204EDEa4A7bE70f544bfe8BEFA8C43F3C198B1b |
| PointsSale | 0x5121F2f9D59E558a2aE83EE31111DEF781923de2 |
| USDC | 0xE9A198d38483aD727ABC8b0B1e16B2d338CF0391 |
⚠️ Important: Testnet contracts are separate from mainnet. Testnet tokens have no real value. See Testnet Guide for details.
Performance Characteristics
- Event Processing: < 200ms average
- LTZ Distribution: < 3 seconds
- Gasless Transactions: < 5 seconds
- SDK Load Time: < 50ms
- Global Availability: 99.9% uptime
Scalability
The Worker architecture provides:
- Infinite horizontal scaling via Cloudflare edge
- No infrastructure management required
- Pay-per-request pricing model
- Zero cold starts (Workers are always warm)
Next Steps
- Quick Start Guide - Integrate in 5 minutes
- SDK Reference - Complete SDK documentation
- API Reference - Worker API docs