Purpose
When an employer creates a stream, the contract immediately transfers the full deposit into its own escrow. From that point, funds can only leave the contract in two ways:- Payment to the recipient — after a verified withdrawal is approved (or auto-released after the deadline).
- Refund to the sender — when a stream is cancelled and no funds are reserved for outstanding withdrawals.
rate_per_second × active_duration_seconds. Workers never submit their own payment figure; the contract enforces it.
Data Structures
StreamRecord
StreamRecord
The primary record stored for every stream. Read it with
get_stream(stream_id).WithdrawalRecord
WithdrawalRecord
Created by
verify_work (or request_withdrawal in legacy mode). Each record represents one work session payment.WithdrawalStatus enum
WithdrawalStatus enum
The lifecycle of a single withdrawal request.
StreamStatus enum
StreamStatus enum
The lifecycle state of a stream.
Public Entrypoints
create_stream
Creates a new payment stream and transfers the full deposit into escrow.
Address
required
The employer’s Stellar address. Must authorize this transaction. Must differ from
recipient.Address
required
The worker’s Stellar address who will receive payments.
i128
required
Payment rate in Stellar 7-decimal fixed-point per second. For example,
1_0000000 = 1 XLM/s. Must be greater than 0.Address
required
Stellar asset contract address. Use the XLM SAC address or the testnet USDC contract.
i128
required
Total escrow amount in 7-decimal fixed-point. Must be at least
rate_per_second × 5 × duration_ledgers.u32
required
Scheduled stream length in ledgers (approximately 5 seconds per ledger). Must be greater than 0.
u32
Legacy parameter. Pass
0 — the contract ignores this value in work-session mode.u32
Legacy parameter. Pass
0 — the contract ignores this value in work-session mode.u32
required
Number of ledgers the employer has to approve or dispute after
verify_work is called. After this deadline the worker can call withdraw_approved without explicit employer action. Must be greater than 0.Category
required
One of
Freelance, Salary, Bounty, Grant, AgentTask, or Subscription. Affects reputation scoring weights.String
required
Human-readable stream name. Maximum 80 UTF-8 bytes.
verify_work
Called exclusively by the Aven verifier service. Reserves funds for one completed work session and creates a WithdrawalRecord in Pending status.
You do not call
verify_work directly. It is signed by the Aven verifier service after the CLI submits a work-session report. The contract independently recalculates rate_per_second × active_duration_seconds and rejects the call if the reported amount does not match.request_withdrawal
Legacy direct-request path. Disabled whenever the verifier is configured.
approve_withdrawal
Called by the employer to approve a Pending withdrawal.
sender must be the stream’s original employer address and must authorize the transaction. Moves the WithdrawalRecord status from Pending → Approved.
dispute_withdrawal
Called by the employer to dispute a Pending withdrawal.
Disputed and releases the reserved amount back to unreserved escrow so future sessions can use it. Cannot be called on an already-approved or withdrawn record.
withdraw_approved
Called by the recipient to transfer an approved (or auto-released) payment.
mint_attestation on the Attestation Contract. If this payment completes the stream (total_withdrawn == total_deposited), a second StreamCompletion attestation is minted for reputation scoring.
Auto-release applies when the current ledger is at or past deadline_ledger and the record is still in Pending status — the employer did not act within the timeout window.
Stream Lifecycle Management
caller to be the stream’s sender and to authorize the transaction.
pause_stream— moves anActivestream toPaused. Records the current ledger so paused time can be tracked. New work sessions cannot be verified on a paused stream.resume_stream— moves aPausedstream back toActive. Accumulates the paused duration.cancel_stream— cancels anActiveorPausedstream. Returns all unreserved escrow to the sender. Fails with Error 36: OutstandingWithdrawals if any funds are currently reserved for pending withdrawals — resolve those first.
Read-Only Queries
Contract Events
The Stream Contract emits the following events. You can subscribe to them via the Stellar Horizon events API or thestellar-sdk event stream.
