Skip to content

jessicanath/paystream-contracts

 
 

Repository files navigation

PayStream Contracts

CI License: Apache 2.0

Soroban smart contracts for PayStream — decentralized payroll and salary streaming on the Stellar blockchain.

PayStream lets employers stream salaries to employees in real-time, per-second. Instead of waiting for a monthly paycheck, employees earn and can withdraw their salary continuously as they work — fully on-chain, trustless, and transparent.


Why PayStream?

  • Real-time pay — employees access earned wages any time, not just payday
  • Trustless escrow — funds locked on-chain; employer cannot claw back earned salary
  • Transparent — every stream, withdrawal, and cancellation is an immutable on-chain event
  • Stellar-native — built on Stellar's fast, low-fee infrastructure with Soroban smart contracts
  • Flexible — pause, resume, top-up, or cancel streams; optional hard stop time

Project Structure

.
├── contracts
│   ├── stream              # Core salary streaming and escrow contract
│   │   ├── src
│   │   │   ├── lib.rs      # Stream entrypoints
│   │   │   ├── storage.rs  # Persistence and claimable calculation
│   │   │   ├── events.rs   # On-chain event publishing
│   │   │   ├── types.rs    # Domain models and storage keys
│   │   │   └── test.rs     # Contract tests
│   │   └── Cargo.toml
│   └── token               # Fungible payment token contract
│       ├── src
│       │   ├── lib.rs
│       │   ├── storage.rs
│       │   ├── types.rs
│       │   └── test.rs
│       └── Cargo.toml
├── scripts
│   ├── build.sh
│   ├── deploy-local.sh
│   ├── deploy-testnet.sh
│   └── init-testnet.sh
├── Cargo.toml
├── Makefile
├── CONTRIBUTING.md
├── SECURITY.md
└── README.md

Quick Start

Prerequisites

git clone https://github.com/Vera3289/paystream-contracts.git
cd paystream-contracts
rustup target add wasm32-unknown-unknown

Build

make build
# or: stellar contract build

Test

make test
# or: cargo test

Format & Lint

make fmt-check
make lint

Stream Contract Reference

Functions

Function Caller Description
initialize(admin) Admin Set contract admin
create_stream(employer, employee, token, deposit, rate_per_second, stop_time) Employer Create stream, lock deposit
withdraw(employee, stream_id) Employee Withdraw all claimable earnings
top_up(employer, stream_id, amount) Employer Add more funds to active stream
pause_stream(employer, stream_id) Employer Pause accrual
resume_stream(employer, stream_id) Employer Resume accrual
cancel_stream(employer, stream_id) Employer Pay employee earned share, refund remainder
get_stream(stream_id) Anyone Read stream state
claimable(stream_id) Anyone Query withdrawable amount right now
stream_count() Anyone Total streams created

Stream Status Lifecycle

Active → Paused → Active
Active → Cancelled
Active → Exhausted  (deposit fully streamed)

Claimable Calculation

claimable = min(
    (now - last_withdraw_time) * rate_per_second,
    deposit - withdrawn
)

Time is capped at stop_time if set. Paused time is excluded.


Deployment

Testnet

./scripts/build.sh
./scripts/deploy-testnet.sh

export STELLAR_ADMIN_ADDRESS=<YOUR_PUBLIC_KEY>
export TOKEN_CONTRACT_ID=<FROM_DEPLOY>
export STREAM_CONTRACT_ID=<FROM_DEPLOY>
./scripts/init-testnet.sh

Local

make deploy-local

Technology Stack

Layer Technology
Blockchain Stellar (Soroban)
Language Rust
SDK Soroban SDK v22.0.0
CI/CD GitHub Actions

Contributing

See CONTRIBUTING.md.

Security

See SECURITY.md. Report vulnerabilities to [email protected] — not via public issues.

License

Apache 2.0


Built with ❤️ on Stellar

About

Soroban smart contracts for PayStream — decentralized per-second salary streaming on Stellar. Employer escrow, real-time withdrawals, pause/resume/cancel, and on-chain audit trail.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 89.6%
  • Shell 8.9%
  • Makefile 1.5%