Complete documentation for the FlowStar payment streaming smart contract.
- API Reference - Complete function reference with parameters, returns, and gas costs
- Integration Guide - Step-by-step guide with 5 practical examples
- CLI Examples - Command-line interface examples for contract interaction
FlowStar is a Stellar Soroban smart contract that enables token streaming with flexible vesting schedules. It allows senders to create streams that recipients can withdraw from gradually over time, with optional cliff vesting.
- Linear Streaming: Recipients receive tokens continuously throughout the stream duration
- Cliff Vesting: Define an amount that unlocks immediately at a specified time
- Flexible Configuration: Customize start time, end time, cliff, and amounts
- Recipient Rights: Recipients can withdraw available balance at any time
- Sender Control: Senders can cancel streams and receive remaining balance
- Stream Transfer: Recipients can transfer their stream rights to another address
- Top-up Support: Senders can add more funds to existing streams
- Storage Management: Built-in TTL bumping for long-term streams
Start with the API Reference to understand all 12 public functions:
-
Stream Creation & Modification
create_stream()- Create a new payment streamcancel()- Cancel a streamtransfer_stream()- Transfer stream to new recipienttop_up()- Add funds to existing streambump_stream()- Extend stream TTL
-
Recipient Operations
withdraw()- Withdraw available funds
-
Query Functions
get_stream()- Fetch stream detailsget_withdrawable()- Get available withdrawal amountget_sent_streams()- List streams sent by addressget_received_streams()- List streams received by addressget_sent_stream_count()- Count of sent streamsget_received_stream_count()- Count of received streams
Follow the Integration Guide which includes:
- Quick Start (5 minutes)
- 5 Complete Examples:
- Payroll System
- Vesting with Cliff
- Airdrop Distribution
- Real-time Balance Display
- Token Approval Flow
- Error Handling
- Best Practices
Use the CLI Examples for direct contract interaction via soroban-cli:
- Creating streams with various configurations
- Querying stream data
- Withdrawing funds
- Modifying and cancelling streams
- Batch operations
- Debugging tools
Create monthly salary streams for employees:
Employee receives salary gradually over 30 days
- 1 month cliff to verify employment
- Linear vesting for remaining salary
- Automatic withdrawals each period
Distribute tokens to founders, investors, and employees:
Token vesting with staggered release
- 6-month cliff (25% unlocks)
- 4-year linear vesting for remaining 75%
- Investor can transfer stream rights
Distribute tokens to many recipients fairly:
Airdrop tokens over 30 days
- Equal amount per recipient
- Linear distribution
- Batch creation from CSV
All write operations require authorization from a specific account:
| Operation | Requires |
|---|---|
create_stream() |
Sender must authorize |
withdraw() |
Recipient must authorize |
cancel() |
Sender must authorize |
transfer_stream() |
Current recipient must authorize |
top_up() |
Sender must authorize |
bump_stream() |
Sender must authorize |
Query operations (read-only) do not require authorization or fees.
| Code | Name | Meaning |
|---|---|---|
| 1 | NotFound | Stream does not exist |
| 2 | Unauthorized | Caller not authorized for operation |
| 3 | InvalidAmount | Amount is invalid (≤0 or > total) |
| 4 | InvalidTime | Time values invalid (start ≥ end) |
| 5 | InvalidCliff | Cliff configuration invalid |
| 6 | AlreadyCancelled | Stream already cancelled |
| 7 | InsufficientFunds | Not enough balance for operation |
| 8 | InvalidToken | Token contract not SEP-41 valid |
| 9 | TransferFailed | Token transfer failed (allowance?) |
| 10 | InsufficientWithdrawable | No funds available yet |
See API Reference - Error Codes for details.
Approximate costs on Stellar Soroban (in stroops, 1 XLM = 10^7 stroops):
| Operation | Cost |
|---|---|
| create_stream | 575,000 stroops (~0.0058 XLM) |
| withdraw | 230,000 stroops (~0.0023 XLM) |
| cancel | 172,500 stroops (~0.0017 XLM) |
| transfer_stream | 115,000 stroops (~0.0012 XLM) |
| top_up | 230,000 stroops (~0.0023 XLM) |
| bump_stream | 115,000 stroops (~0.0012 XLM) |
| get_stream (query) | Free |
| get_withdrawable (query) | Free |
interface Stream {
id: u64;
sender: Address;
recipient: Address;
token: Address;
deposited_amount: i128;
withdrawn_amount: i128;
start_time: u64;
end_time: u64;
cliff_time: u64;
cliff_amount: i128;
amount_per_second: i128;
cancelled: boolean;
}
interface StreamParams {
recipient: Address;
token: Address;
total_amount: i128;
start_time: u64;
end_time: u64;
cliff_time: u64;
cliff_amount: i128;
}- Network: Stellar Testnet
- Passphrase:
Test SDF Network ; September 2015 - RPC Endpoint:
https://soroban-testnet.stellar.org - Horizon Endpoint:
https://horizon-testnet.stellar.org
- Network: Stellar Public Network
- Passphrase:
Public Global Stellar Network ; September 2015 - RPC Endpoint:
https://soroban-mainnet.stellar.org - Horizon Endpoint:
https://horizon.stellar.org
Q: What happens if I cancel a stream? A: All remaining funds are immediately returned to the sender's token account.
Q: Can I withdraw partially? A: Yes! You can withdraw any amount up to the currently available balance.
Q: How often should I bump the stream TTL?
A: Streams last ~6 months before needing a bump. Call bump_stream() every 5 months for active streams.
Q: What tokens are supported? A: Any SEP-41 token on Stellar is supported. Common tokens include XLM, USDC, and EURC.
Q: Can I transfer my stream to someone else?
A: Yes! Call transfer_stream() to transfer your recipient rights to another address.
Q: What's the maximum stream duration? A: Theoretically unlimited, but practical limit is ~6 months before TTL bump needed.
Run tests against the contract:
cd contracts/streaming
cargo testDeploy to Testnet:
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/streaming.wasm \
--source GXXXXXXFor issues, questions, or contributions:
- Check this documentation
- Review API Reference for function details
- See Integration Guide for examples
- Check CLI Examples for command reference
FlowStar is open source and available under the MIT License.
Last Updated: 2026-06-25 Documentation Version: 1.0 Smart Contract Version: 1.0