This guide provides comprehensive documentation for backend and smart contract developers to integrate with the StableStream USDC payment streaming platform.
- Overview
- Architecture
- Smart Contract Requirements
- API Endpoints
- Data Models
- Authentication
- Real-time Updates
- Environment Variables
- Testing
- Deployment
StableStream is a USDC payment streaming platform that allows users to create continuous payment streams that flow by the second. The platform consists of:
- Frontend: Next.js 16 application with React 19
- Smart Contracts: Solidity contracts for managing payment streams
- Backend API: RESTful API for user data and analytics
- WebSocket: Real-time updates for stream balances
``` ┌─────────────┐ ┌──────────────┐ ┌─────────────┐ │ Frontend │────▶│ Backend API │────▶│ Database │ │ (Next.js) │ │ (REST/WS) │ │ (PostgreSQL)│ └─────────────┘ └──────────────┘ └─────────────┘ │ │ │ │ ▼ ▼ ┌─────────────┐ ┌──────────────┐ │ Wallet │ │ Smart │ │ (RainbowKit)│────▶│ Contracts │ └─────────────┘ └──────────────┘ ```
The main contract should manage payment streams with the following functionality:
// Create a new payment stream
function createStream(
address recipient,
uint256 amount,
uint256 startTime,
uint256 endTime
) external returns (uint256 streamId);
// Pause an active stream
function pauseStream(uint256 streamId) external;
// Resume a paused stream
function resumeStream(uint256 streamId) external;
// Cancel a stream and refund remaining balance
function cancelStream(uint256 streamId) external returns (uint256 refundAmount);
// Withdraw available balance from a stream
function withdraw(uint256 streamId) external returns (uint256 amount);
// Get stream details
function getStream(uint256 streamId) external view returns (Stream memory);
// Calculate available balance for withdrawal
function balanceOf(uint256 streamId) external view returns (uint256);