Skip to content

Production-grade streaming payments protocol on Solana with trustless escrow, configurable vesting schedules, and real-time token distribution. Designed for freelance work, DAO employment, and decentralized bounty programs.

Notifications You must be signed in to change notification settings

ANISH-SR/StreamVault

Repository files navigation

StreamVault

A decentralized streaming payments protocol built on Solana, enabling continuous token transfers with linear vesting schedules, milestone-based releases, and comprehensive escrow management.

Overview

StreamVault is a production-grade Solana protocol that revolutionizes how payments are distributed in decentralized work environments. Unlike traditional payment systems that rely on manual milestone approvals or fixed payment schedules, StreamVault enables continuous, real-time token streaming based on elapsed time, providing a trustless and transparent payment infrastructure for the Web3 economy.

The Problem

Traditional freelance and decentralized work payment systems face several critical challenges:

  • Employers must trust freelancers to deliver before releasing funds, or freelancers must trust employers to pay after completion
  • Fixed milestone payments don't accurately reflect continuous value delivery throughout a project
  • Manual payment approvals create friction and delays in the payment process
  • International payments incur high fees and settlement times
  • Dispute resolution lacks transparency and on-chain enforcement mechanisms

The Solution

StreamVault addresses these challenges through a sophisticated dual-program architecture that separates payment streaming logic from escrow fund management:

Continuous Streaming Payments: Tokens flow automatically from employer to freelancer based on elapsed time, eliminating the need for manual approvals while maintaining security through smart contract escrow. Freelancers can withdraw earned funds at any time without waiting for milestone completion.

Flexible Vesting Schedules: The protocol supports multiple distribution models including linear vesting, exponential acceleration curves (quadratic/cubic), milestone-based releases, and hybrid combinations. This flexibility accommodates different work arrangements and risk profiles.

Trustless Escrow System: Funds are held in program-derived addresses (PDAs) with multi-party authorization. Neither party can unilaterally access funds inappropriately, yet both retain the ability to pause streams or initiate disputes when necessary.

Pause-Aware Calculations: The protocol automatically adjusts payment calculations when streams are paused, ensuring accurate fund distribution even when work is temporarily halted. This feature is critical for handling scope changes, vacations, or project delays.

Technical Architecture

StreamVault employs a modular dual-program design:

  1. Stream Vault Program: Manages the streaming payment lifecycle, calculates earned amounts using pluggable strategies, and enforces business logic for withdrawals and cancellations.

  2. Vault Program: Provides secure token custody through PDAs, implements flexible release schedules, handles multi-party authorization, and manages escrow state transitions.

This separation of concerns enables the Vault program to serve as reusable financial infrastructure for future programs such as bounty systems, grant distributions, and staking mechanisms.

Key Technical Capabilities

  • High-Performance Calculations: Optimized streaming algorithms using u128 arithmetic with overflow protection ensure accurate fund distribution at scale
  • Gas Efficiency: Strategic use of PDAs and account compression minimizes compute unit consumption
  • Mathematical Correctness: Comprehensive property-based testing using QuickCheck, PropTest, and Arbtest validates calculation accuracy across edge cases
  • Security-First Design: Multiple layers of protection including reentrancy guards, arithmetic safety checks, and authorization validation
  • Composable Architecture: Clean separation between streaming logic and escrow management enables ecosystem-wide reusability

Use Cases

StreamVault is designed for various decentralized work scenarios:

  • Freelance Contracts: Continuous payment streaming for ongoing development, design, or content creation work
  • DAO Employment: Transparent, automated salary distribution for DAO contributors
  • Bounty Programs: Milestone-based releases with dispute resolution for open-source contributions
  • Grant Distribution: Time-locked vesting schedules for ecosystem grants and funding programs
  • Escrow Services: Secure fund custody for any multi-party financial arrangement requiring trustless intermediation

Key Features

Streaming Payments

  • Linear vesting schedules with customizable acceleration curves
  • Real-time fund availability calculations
  • Continuous token streaming without manual intervention

Escrow Management

  • Secure fund custody with multi-party authorization
  • Milestone-based release mechanisms
  • Dispute resolution with arbiter support
  • Automated refund capabilities

Flexible Release Schedules

  • Immediate release
  • Time-based linear vesting
  • Milestone-based conditional releases
  • Hybrid linear and milestone combinations

Security & Reliability

  • Comprehensive access control mechanisms
  • Reentrancy protection
  • Arithmetic overflow safeguards
  • Emergency pause functionality

Architecture

The StreamVault protocol consists of two primary programs:

  1. Stream Vault Program: Manages streaming payment schedules and fund distribution
  2. Vault Program: Handles escrow operations and token custody

For detailed architectural information, refer to the Architecture Diagram.

Documentation

Prerequisites

  • Node.js v16 or higher
  • Yarn package manager
  • Rust 1.70 or higher
  • Solana CLI 1.16 or higher
  • Anchor Framework 0.29.0

Installation

Clone the repository:

git clone https://github.com/ANISH-SR/StreamVault.git
cd StreamVault

Install dependencies:

yarn install

Building the Program

Build the Solana programs:

anchor build

Testing

Run the complete test suite:

anchor test

Run specific test categories:

# Run improved test suite
./run-improved-tests.sh

# Run test summary
./run-test-summary.sh

Deployment

Devnet Deployment

The StreamVault program is currently deployed on Solana Devnet:

Program ID: qz9T2r5v4guvijmCw7Bt8K43c2aFdaRV9ahRuQbzP5Q

Explorer: View on Solana Explorer

Deployment Signature: 5SFUZkatDkuBhJW59YUzUdcNSaDUkGZPMRfjVzFUUmzXkJSzYwhVXBLNmU5Hw1mRNYq

Deploy to Your Own Environment

Configure your Solana CLI for the desired network:

# For devnet
solana config set --url https://api.devnet.solana.com

# For localnet
solana config set --url http://localhost:8899

Deploy the program:

anchor deploy

Project Structure

StreamVault/
├── programs/
│   ├── stream_vault/     # Main streaming payment program
│   └── vault/            # Escrow and vault management program
├── tests/                # Integration and unit tests
├── docs/                 # Additional documentation
├── migrations/           # Deployment migrations
└── Anchor.toml          # Anchor configuration

Configuration

The project uses Anchor.toml for configuration. Key settings include:

  • Cluster: Configured for localnet by default
  • Wallet: Uses ~/.config/solana/id.json
  • Programs: Defines program IDs for different networks

Usage Example

import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { StreamVault } from "../target/types/stream_vault";

// Initialize program
const program = anchor.workspace.StreamVault as Program<StreamVault>;

// Create a streaming payment
await program.methods
  .createStream({
    recipient: recipientPublicKey,
    amount: new anchor.BN(1000000),
    startTime: new anchor.BN(Date.now() / 1000),
    endTime: new anchor.BN(Date.now() / 1000 + 86400),
  })
  .accounts({
    // Account configuration
  })
  .rpc();

Contributing

Contributions are welcome. Please ensure all tests pass before submitting pull requests.

# Run linter
yarn lint

# Fix linting issues
yarn lint:fix

Security

This protocol handles financial transactions and should be thoroughly audited before production use. The codebase includes:

  • Comprehensive test coverage
  • Property-based testing with QuickCheck and PropTest
  • Edge case validation
  • Frozen token recovery mechanisms

For security concerns, please review the Edge Case Report and Frozen Token Recovery.

License

ISC

Author

ANISH-SR

Acknowledgments

Built with Anchor Framework on Solana blockchain.

About

Production-grade streaming payments protocol on Solana with trustless escrow, configurable vesting schedules, and real-time token distribution. Designed for freelance work, DAO employment, and decentralized bounty programs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages