PPM Contract
The Pay-Per-Minute (PPM) contract manages tMETIS allowances and automatic withdrawals for group vibestreams with real-time pricing. Each allowance is tied to a specific vibeID to ensure isolated spending authorization.Contract Overview
Standard: Custom payment processing contractFeatures: Time-based payments, allowance management, automatic distribution
Security: Reentrancy protection, emergency controls, pausable operations
Core Concepts
Participant Allowances
Each participant’s spending authorization is tracked per vibestream:Vibestream Configuration
Each registered vibestream has associated configuration:Payment Flow
1. Vibestream Registration
Only the VibeFactory can register vibestreams:2. Spending Authorization
Participants authorize spending for specific vibestreams:- Must send tMETIS equal to
authorizedAmount - Amount must not exceed
MAX_ALLOWANCE(1000 tMETIS) - Vibestream must be registered and active
- Validates payment amount
- Creates or updates participant allowance
- Refunds excess payment if any
- Emits
AllowanceAuthorizedevent
3. Joining Vibestreams
Participants join active vibestreams to begin payment processing:- Must have sufficient allowance (≥ one minute of payments)
- Cannot already be active in the vibestream
- Vibestream must be registered
- Sets participant as active
- Records join timestamp
- Adds to active participants list
- Starts payment timer
4. Real-Time Payment Processing
Payments are processed automatically every 60 seconds:- Calculate elapsed time since last deduction
- Determine minutes elapsed (minimum 60 seconds)
- Calculate amount owed:
minutes × payPerMinute - Distribute payment: 80% creator, 20% treasury
- Update participant’s spent amount and last deduction timestamp
5. Leaving Vibestreams
Participants can leave vibestreams to stop payments:- Processes final payment for elapsed time
- Sets participant as inactive
- Removes from active participants list
- Emits
ParticipantLeftevent
Advanced Features
Allowance Management
Increasing Allowances
Emergency Stop
- Contract owner
- Participant themselves
- Vibestream creator
Payment Constants
| Constant | Value | Description |
|---|---|---|
MIN_PAYMENT_INTERVAL | 60 seconds | Minimum time between payments |
MAX_ALLOWANCE | 1000 tMETIS | Maximum allowance per transaction |
treasuryFeePercent | 20% | Treasury fee on all payments |
GAS_LIMIT | 50,000 | Gas limit for external transfers |
Security Features
Per-VibeID Isolation
Each allowance is tied to a specific vibestream, preventing cross-contamination:Reentrancy Protection
All payable functions use OpenZeppelin’snonReentrant modifier: