Skip to main content
A stream flows money continuously between two wallets. This guide walks through opening a stream, monitoring it, and cleanly terminating it.

Scenario

You’re paying a contractor $50/day as a stream rather than a monthly invoice. The recipient can withdraw earned balance any time; you can top up or cancel at will.

1. Calculate the flow rate

Use more digits in practice to avoid rounding error:

2. Open the stream

Under the hood, the API wraps initial_deposit into the stream’s escrow (stream accounting is on-chain for stablecoin streams). From that moment, the recipient accrues at flow_rate per second.

3. Recipient withdraws (on their schedule)

The recipient can withdraw any time:
Withdrawals create stream_withdraw transfer records.

4. Monitor runway

Runway = remaining wrapped balance / flow rate. When it crosses thresholds, Sly fires:
  • stream.alert webhook with severity: warning (<24h)
  • severity: critical (<1h)
  • severity: exhausted (runway = 0, stream auto-pauses)

5. Adjust mid-stream

Top up runway:
Change flow rate:
Pause / resume:

6. Cancel cleanly

On cancel:
  • Accrued balance transfers to the recipient
  • Unused wrapped funds return to the sender
  • Stream transitions to cancelled but the audit record stays

Permission scoping for agents

If an agent manages the stream, grant granular permissions:

Common patterns

Payroll for many contractors: one parent wallet with many streams, one per contractor. When someone leaves, cancel their stream — remaining funds refund automatically. Subscription billing: open a stream from the customer to you; cancellation requires no refund logic because unused time returns automatically. AI compute billing: open a stream from the customer’s agent to your API service; flow rate set to match the customer’s per-request cost × expected RPS. Bill exactly what they used, no more.

Gotchas

  • Flow rates must be reasonable. Ultra-tiny flow rates (10^-12) cause rounding issues on some chains. Stick to 6-8 decimal places.
  • Paused streams don’t warn. A paused stream can sit for weeks; it won’t alert you it’s not accruing.
  • Network fees on wrap/unwrap. Each stream wraps funds once at creation and unwraps once at cancel. Gas cost is trivial on L2s but visible.