Skip to content

Ghislo749/streampay

Repository files navigation

StreamPay ⚑

Interval-based payment streaming on Bitcoin via Stacks. Payments unlock at fixed intervals, withdraw anytime, settle instantly.

License: MIT Stacks Testnet


🎯 Problem

Traditional payments are discrete and inflexible:

  • πŸ’Ό Employees wait weeks for paychecks β†’ cash flow problems
  • 🎨 Freelancers invoice monthly β†’ delayed payment, uncertainty
  • πŸ“Ί Subscriptions charge upfront β†’ paying for unused time
  • 🀝 Grant recipients get lump sums β†’ no accountability, misaligned incentives

Result: Inefficient capital allocation, trust issues, and financial stress.


πŸ’‘ Solution

StreamPay enables continuous, interval-based payment streams on Stacks using SIP-010 tokens (USDCx, STX, sBTC).

Core Features

  • ⚑ Flexible Intervals: Per block, hourly, daily, or custom
  • πŸ’° Anytime Withdrawals: Recipients access earned funds 24/7
  • ⏸️ Pause / Resume: Senders can pause streams (settles owed amount first)
  • πŸ” Top-up: Extend stream duration by adding more funds
  • πŸ”’ Bitcoin-Secured: Built on Stacks L2, inheriting Bitcoin security
  • 🌐 Multi-Token: Any SIP-010 fungible token
  • πŸ“Š Event Logging: All actions emit indexable on-chain events

Advanced Capabilities

  • 🎯 Lazy Accounting: Gas-efficient on-demand calculations
  • πŸ›‘οΈ Safety Limits: Rate, interval, and deposit caps
  • πŸ”„ BNS Integration: Human-readable .btc addresses
  • βœ… Instant Settlement: Cancel streams with automatic prorated refunds
  • πŸ“± Real-Time Updates: Frontend refreshes every 30 seconds

πŸš€ Live Demo

Try it now (no installation required):

Quick Start (Judges)

  1. Visit the live app
  2. Connect Hiro or Leather wallet (testnet)
  3. Mint test USDCx
  4. Create a stream
  5. Withdraw in real time

✨ Key Innovations

1. Interval-Based Streaming

Supports custom payment intervals, not only per-block:

  • Hourly (~720 blocks)
  • Daily (~17,280 blocks)
  • Custom (1 to 100M blocks)

This aligns payments with real-world billing cycles while remaining gas-efficient.

2. Pause Without Losing Funds

Pausing a stream:

  1. Settles all owed funds
  2. Freezes accrual
  3. Can resume at any time

No funds are lost.

3. Dynamic Top-Ups

Extend streams by adding funds mid-stream:

// 100 USDCx for 100 days
// +50 USDCx top-up
// β†’ Stream now lasts 150 days

4. Multi-Token via SIP-010

(define-public (create-stream
  (recipient principal)
  (rate uint)
  (deposit uint)
  (interval uint)
  (token <ft-trait>)
))

Works with any present or future SIP-010 token.


πŸ—οΈ Architecture

High-Level Flow

Sender ── Create Stream ──► Contract ──► Recipient
         Deposit Funds               Withdraw Anytime

Lazy Accounting Formula

intervals = (current-block - last-withdraw-block) / interval
ewarned = intervals * rate
owed = min(earned, remaining-deposit)

πŸ› οΈ Technology Stack

Smart Contracts

  • Language: Clarity 2.0
  • Network: Stacks Testnet
  • Standard: SIP-010
  • Tooling: Clarinet

Frontend

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Wallets: Hiro, Leather
  • Styling: Tailwind CSS
  • Deployment: Vercel

πŸ“¦ Local Setup

# Clone repository
git clone https://github.com/Ghislo749/streampay
cd streampay/frontend

npm install
npm run dev

Open http://localhost:3000


πŸ”’ Security Highlights

  • Integer overflow protection (Clarity-native)
  • Strict sender / recipient authorization
  • Reentrancy-safe execution model
  • Idempotent withdrawals
  • Input safety limits
Scenario Safe
Same-block withdraw βœ…
Pause without owed βœ…
Interval = 0 ❌ Rejected

πŸ—ΊοΈ Roadmap

Phase 1 β€” Complete

  • Core streaming
  • Pause / Resume
  • Top-ups
  • Multi-token support
  • Testnet deployment

Phase 2 β€” Enhancements

  • Batch operations
  • Stream templates
  • Scheduled streams
  • Analytics dashboard

Phase 3 β€” Integrations

  • STX402 API (micropayment-based)
  • DAO & bounty streaming
  • Cross-chain support

πŸ“„ License

MIT β€” see LICENSE


πŸ‘€ Author

YOUR NAME


Built on Stacks Β· Secured by Bitcoin Β· Powered by USDCx

Making payments flow like time itself ⏰

About

Interval-based payment streaming on Stacks with USDCx - pause, resume, and top-up streams anytime

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors