Contract Address
Testnet:CAZSE5UHSWNF62K26OZKOL7BSFB2647CXRPOICHUDCUJ5EKS4NCOA6ZA
Key Functions
For Clients
function → u64
Creates a new payment stream and immediately locks the client’s funds in the contract. Returns the new
stream_id.Parameters:sender— The client’s Stellar address (must authorize)recipient— The worker’s Stellar addressrate_per_second— Payment rate in stroops per secondasset— Token contract address (USDC or XLM)total_deposited— Total amount to lock in escrow (stroops)duration_ledgers— Stream duration in Stellar ledgerscheckpoint_count— Number of payment checkpoints (1–30)withdrawable_cap_percent— Percentage of earned funds releasable before checkpoint approvalapproval_timeout_ledgers— Ledgers before a pending request auto-releasescategory— Work category (Freelance,Salary,Bounty,Grant,AgentTask,Subscription)title— Human-readable stream name (max 80 bytes)
function → ()
Pauses an active stream, freezing the payment clock. Only the sender (client) may call this. The stream accumulates
paused_duration_ledgers so that elapsed time is tracked accurately on resume.Parameters:stream_id— ID of the stream to pausecaller— Must match the stream sender
function → ()
Resumes a paused stream and restarts the payment clock from where it stopped. Only the sender may call this.Parameters:
stream_id— ID of the stream to resumecaller— Must match the stream sender
function → ()
Cancels an active or paused stream. Earned-but-unpaid funds are transferred to the worker immediately; remaining unearned funds are refunded to the client.Parameters:
stream_id— ID of the stream to cancelcaller— Must match the stream sender
function → ()
Explicitly approves a pending withdrawal request, allowing the worker to claim funds without waiting for the auto-release timeout.Parameters:
stream_id— ID of the streamsender— Must match the stream senderrequest_id— The withdrawal request identifier
function → ()
Marks a pending withdrawal request as disputed, preventing auto-release and freeing the reserved funds back into the withdrawable pool.Parameters:
stream_id— ID of the streamsender— Must match the stream senderrequest_id— The withdrawal request identifier
function → u64
Explicitly approves a submitted checkpoint, triggering immediate finalization and attestation minting. Returns the new
attestation_id.Parameters:stream_id— ID of the streamsender— Must match the stream senderindex— Zero-based checkpoint index
For Workers
function → ()
Submits a withdrawal request for a completed work period. Only available when no verifier is configured on the contract. When a verifier is set, use the dashboard flow instead — the verifier calls
verify_work on your behalf.Parameters:stream_id— ID of the streamrecipient— Must match the stream recipient (must authorize)request_id— Unique string identifier for this request (max 64 bytes)amount— Amount to request in stroops
function → i128
Executes an approved (or auto-released) withdrawal, transferring tokens to the worker and minting an attestation atomically. Returns the amount transferred.Parameters:
stream_id— ID of the streamrecipient— Must match the stream recipient (must authorize)request_id— The approved withdrawal request identifier
function → ()
Submits evidence for a checkpoint period, signalling to the client that work is ready for review.Parameters:
stream_id— ID of the streamworker— Must match the stream recipient (must authorize)index— Zero-based checkpoint indexevidence_hash— 32-byte SHA-256 hash of the work evidence
Verifier-Only (Dashboard)
function → ()
Called by the Aven dashboard’s verifier key after validating a work session report. Creates a
WithdrawalRecord with the verified evidence hash and reserves the funds for payout. The worker then calls withdraw_approved to complete the transfer and mint the attestation.Parameters:stream_id— ID of the streamrequest_id— Unique session identifier (max 64 bytes)amount— Verified payment amount in stroopsevidence_hash— 32-byte hash of the verified session reportactive_duration_seconds— Active working seconds in the sessionwork_start_ledger— Ledger sequence when the session started
Read Functions
function → StreamRecord
Returns the full
StreamRecord for the given stream ID.function → Vec<u64>
Returns all stream IDs where the given address is the sender.
function → Vec<u64>
Returns all stream IDs where the given address is the recipient.
function → i128
Returns the amount currently available for withdrawal — earned funds minus already-reserved pending requests.
function → i128
Returns the total earned (withdrawable) amount for the stream based on elapsed active ledgers and checkpoint unlock status.
function → WithdrawalRecord
Returns the
WithdrawalRecord for a specific (stream_id, request_id) pair.function → CheckpointRecord
Returns the
CheckpointRecord for a specific (stream_id, index) pair.function → u32
Scans all elapsed checkpoint periods for the given stream and finalizes any that are unlocked (either explicitly approved or past the auto-approval timeout). Returns the number of checkpoints settled. Can be called by anyone.Parameters:
stream_id— ID of the stream to settle
StreamRecord Fields
TheStreamRecord struct is returned by get_stream. Its fields describe the full state of a payment stream.
u64
Unique auto-incrementing stream identifier assigned at creation.
Address
The client’s Stellar address — the account that funded the stream.
Address
The worker’s Stellar address — the account that receives payments.
i128
Payment rate in stroops per Stellar ledger, derived from the per-second rate at creation (
rate_per_second × 5).Address
Token contract address for the streaming asset (USDC or native XLM).
i128
Total amount locked in escrow at stream creation, in stroops.
i128
Cumulative amount already paid out to the worker, in stroops.
u32
Stellar ledger sequence number at which the stream was created.
u32
Total stream duration in Stellar ledgers (approximately 5 seconds each).
StreamStatus
Current lifecycle state:
Active, Paused, Completed, or Cancelled.Category
Work category used to classify the attestations minted from this stream:
Freelance, Salary, Bounty, Grant, AgentTask, or Subscription.String
Human-readable stream name (max 80 UTF-8 bytes), stored on-chain and copied to every attestation.
u32
Number of payment checkpoints dividing the stream duration (1–30).
u32
Ledgers per checkpoint period (
duration_ledgers / checkpoint_count).u32
Percentage of earned funds available before a checkpoint is approved (0–100). Acts as a client protection mechanism.
u32
Number of ledgers a withdrawal request remains pending before it auto-releases without explicit client approval.
u32
Ledger sequence when the stream was last paused.
0 when the stream is active.u32
Cumulative ledgers the stream has spent in the
Paused state. Subtracted from elapsed time during payout calculations.Error Codes
Clients interact with the stream contract through the Aven dashboard, which handles wallet authorization and verifier coordination automatically. Direct contract invocation is possible via Stellar Lab or the Stellar CLI for advanced users who want to inspect or interact with streams programmatically.