SubStream is a Pay-As-You-Go subscription protocol. Instead of monthly credit card charges, fans stream tokens to creators second-by-second. If the fan dislikes the content, they can cancel instantly and get their remaining balance back.
- subscribe: User deposits a buffer (e.g., 50 XLM) and sets a rate.
- 7-day free trial: Streams accrue zero charges for the first 7 days, then automatically charge at the configured paid rate.
- collect: Creator triggers the withdrawal of accumulated seconds.
- cancel: Subscriber stops the stream and refunds unspent tokens (after minimum duration).
- pause_channel / unpause_channel: Creator can pause their channel to stop charges across all active incoming streams during hiatus.
To prevent users from rapidly starting/stopping streams to "scrape" content, the protocol enforces a minimum flow duration of 24 hours. Once a stream is initiated, it cannot be canceled until the minimum duration has elapsed. This protects creators from abuse and ensures meaningful engagement.
- cancel: Subscriber stops the stream and refunds unspent tokens.
- subscribe_group: User streams to a group channel with exactly 5 creators and percentage splits that sum to 100.
- collect_group: Contract automatically splits each collected amount to all 5 creators based on configured percentages.
- Stellar Testnet
- Network: Stellar Testnet
- Contract ID: CAOUX2FZ65IDC4F2X7LJJ2SVF23A35CCTZB7KVVN475JCLKTTU4CEY6L
stateDiagram-v2
[*] --> Trial : subscribe()
Trial --> Active : trial period ends\n(stream begins)
Trial --> Expired : cancel() during trial
Active --> GracePeriod : balance runs low\n(below rate threshold)
Active --> Expired : cancel()
GracePeriod --> Active : top_up() refills balance
GracePeriod --> Expired : balance depleted\nor cancel()
Expired --> [*]
To run the contract tests locally:
cargo testTo build the contract for Wasm:
cargo build --target wasm32-unknown-unknown --releaseTo reduce deployment fees, use the automated WASM compression:
cd contracts/substream_contracts
make build-compressedOr use the compression script:
./scripts/compress_wasm.shThe compression system uses wasm-opt to optimize WASM binaries, typically reducing file sizes by 10-30%, which directly lowers deployment costs on Stellar.
See WASM_COMPRESSION.md for detailed documentation.