Skip to main content

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 contract
Features: 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:
Requirements:
  • Must send tMETIS equal to authorizedAmount
  • Amount must not exceed MAX_ALLOWANCE (1000 tMETIS)
  • Vibestream must be registered and active
Process:
  1. Validates payment amount
  2. Creates or updates participant allowance
  3. Refunds excess payment if any
  4. Emits AllowanceAuthorized event

3. Joining Vibestreams

Participants join active vibestreams to begin payment processing:
Requirements:
  • Must have sufficient allowance (≥ one minute of payments)
  • Cannot already be active in the vibestream
  • Vibestream must be registered
Process:
  1. Sets participant as active
  2. Records join timestamp
  3. Adds to active participants list
  4. Starts payment timer

4. Real-Time Payment Processing

Payments are processed automatically every 60 seconds:
Payment Logic:
  1. Calculate elapsed time since last deduction
  2. Determine minutes elapsed (minimum 60 seconds)
  3. Calculate amount owed: minutes × payPerMinute
  4. Distribute payment: 80% creator, 20% treasury
  5. Update participant’s spent amount and last deduction timestamp

5. Leaving Vibestreams

Participants can leave vibestreams to stop payments:
Process:
  1. Processes final payment for elapsed time
  2. Sets participant as inactive
  3. Removes from active participants list
  4. Emits ParticipantLeft event

Advanced Features

Allowance Management

Increasing Allowances

Allows participants to add more funds to existing allowances without leaving the vibestream.

Emergency Stop

Immediately removes a participant from a vibestream. Can be called by:
  • Contract owner
  • Participant themselves
  • Vibestream creator

Payment Constants

Security Features

Per-VibeID Isolation

Each allowance is tied to a specific vibestream, preventing cross-contamination:

Reentrancy Protection

All payable functions use OpenZeppelin’s nonReentrant modifier:

Emergency Controls

Pausable Operations

Contract can be paused to halt all operations:

Emergency Withdrawal

Owner can withdraw stuck funds in emergencies:

Gas Optimization

Limited External Calls

All external transfers use gas limits to prevent griefing:

Batch Processing

Multiple participants can be processed in a single transaction:

View Functions

Participant Information

Vibestream Information

Events

Core Events

Usage Examples

Authorizing Spending

Joining a Vibestream

Processing Payments

Emergency Exit

Integration with VibeFactory

The PPM contract integrates seamlessly with VibeFactory through automatic registration:

Next Steps

VibeKiosk Contract

Learn about ticket sales

Contract Flows

See interaction diagrams