Architecture Overview
Resonance uses a distributed Cloudflare Worker architecture to provide seamless, gasless blockchain rewards.
System Architecture
Event Tracking Flow
Gasless Transaction Flow
Perk Claiming Flow
Payment & RSNC 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.rsnc.network/sdk.js"></script>
<script>
Resonance.init('YOUR_BRAND_ID');
</script>
2. Event Handler Worker
Purpose: Process events and distribute RSNC rewards
Endpoints:
POST /resonance-api/manual-event- Track eventsPOST /resonance-api/checkout- Stripe checkoutGET /resonance-api/debug- Health check
Key Functions:
- Event validation
- User wallet creation (via Privy)
- RSNC 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
Purpose: Create wallets for users before they log in (OAuth pregeneration)
Domain: register.rsnc.network
Endpoints:
POST /resonance-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 RSNC tokens. To send rewards, you need to either:
- Use the Event Handler API to create reward distributions
- Use your own RSNC transfer mechanism
- Use the Reward Processor (scheduled worker that processes pending rewards)
5. Stripe Mint Worker
Purpose: Convert fiat payments to RSNC credits
Key Functions:
- Stripe webhook handling
- Payment verification
- RSNC minting
- Balance updates
6. Reward Agent
Purpose: AI-powered loyalty agent for program management and agentic commerce
Domain: agent.rsnc.network
Access Points:
POST /mcp— MCP Streamable HTTP tool callsGET/POST/PATCH /api/v1/*— REST API (45 endpoints)POST /converse— Natural language queriesPOST /tasks/send— A2A protocol- CLI:
npm install -g @resonance/cli
Key Features:
- 45 tools across 17 modules (discovery, brand, user, reward, perks, leaderboard, growth, onboarding, analytics, management, agent rewards, comparison, commerce routing, recommendations, intelligence, network intelligence, suggestions)
- Four access points: MCP, REST API, CLI, A2A
- HMAC-SHA256 + RFC 9421 Ed25519 + OAuth 2.0 authentication
- Cloudflare KV rate limiting
- Workers AI for intelligence, suggestions, and converse
- ERC-8004, A2A, and UCP protocol support
Learn More: Reward Agent Documentation
7. Shopify App
Purpose: Embedded Shopify app for merchant loyalty programs
Domain: rsnc-shopify-app.rsnc.network
Key Features:
- Earning rules (credits per dollar, product filters, time windows)
- Webhook processing (orders/create, customers/create)
- Storefront widget via App Proxy
- Discount code generation for perk redemptions
- D1 database for merchant data
Learn More: Shopify App Documentation
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.rsnc.network/sdk.js | Event tracking |
| Event Handler | api.rsnc.network/resonance-api/* | Backend API |
| Gas Relayer | relayer.rsnc.network/relay | Gasless transactions |
| Pregeneration | register.rsnc.network/resonance-api/pregenerate-user | OAuth wallet creation |
| Partner Portal | partners.rsnc.network | Brand dashboard |
| Perks Marketplace | perks.rsnc.network | Consumer perk discovery & claiming |
| Reward Agent (MCP) | agent.rsnc.network/mcp | AI agent (MCP over HTTP) |
| Reward Agent (REST) | agent.rsnc.network/api/v1/* | REST API (45 endpoints) |
| Shared Services | services.rsnc.network | Streaks, leaderboards, achievements, perks |
| Shopify App | rsnc-shopify-app.rsnc.network | Shopify embedded app |
Testnet (Testing)
| Service | URL | Purpose |
|---|---|---|
| SDK | api.resonance.xyz/sdk.js | Event tracking (testnet) |
| Event Handler | api.resonance.xyz/resonance-api/* | Backend API (testnet) |
| Gas Relayer | relayer.resonance.xyz/relay | Gasless transactions (testnet) |
| Pregeneration | register.resonance.xyz/resonance-api/pregenerate-user | OAuth wallet creation (testnet) |
| Partner Portal | partners.resonance.xyz | Brand dashboard (testnet) |
| Perks Marketplace | perks.resonance.xyz | Consumer perk discovery (testnet) |
📚 Learn More: See the Testnet Guide for complete testnet documentation.
Contract Addresses
Soneium Mainnet (Production)
| Contract | Address |
|---|---|
| Resonance Token | 0x4183CD8fE04bA0f10Ca83cf9E76e58ef8dB7cb33 |
| PerkNFT | 0x997f05E7447Fdde75d47eBb12D4D6C65013AA0Da |
| PointsSale | 0x02939031C36637a4c46d86832D7015a2F350cc7D |
Soneium Minato Testnet (Testing)
| Contract | Address |
|---|---|
| Resonance 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
- RSNC 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