AccrualStream contract, created by a StreamFactory, holding that subscription’s funds in escrow and accruing at a fixed rate per second from the moment it starts. Settlement pulls accrued funds to the merchant in batches; cancel settles the last stretch and refunds what was not used.
Addresses
Read from the deployment record in the repository at build time.
Both modes run on the test network until the mainnet factory is published here. The token is chosen by the mode:
- Test mode escrows the same testnet AUSD. Nothing is minted in either mode: a wallet short of the cap sees the Add funds step and the meter starts once the money lands, so a checkout that passes in test mode behaves the same in live mode.
- Live mode escrows AUSD from Agora. Nothing is minted: a subscriber whose wallet is short sees the Add funds step and needs AUSD sent to it.
Events
AccrualStream emits, per stream:
StreamFactory emits StreamCreated for each new stream. An indexer follows these events and turns them into the Events your webhook endpoint receives; subscription.canceled is a StreamCanceled with the same numbers in decimal dollars.
Settle semantics
- Accrual is continuous, settlement is discrete.
accrued = rate × (now − startedAt − pausedSeconds). A settlement movesaccrued − alreadySettled; nothing is ever charged twice, and nothing accrues while paused. - Whole seconds. Fractions are dropped, never rounded up.
- Cancel settles first, then refunds. The final
Settledand theStreamCanceledland in the same transaction. The refund is escrow minus everything settled. - A cap ends the stream. When elapsed seconds reach the cap the subscriber accepted at checkout, the keeper settles and cancels it; the platform reports that as
subscription.canceledwithended_reason: cap_reached, preceded byinvoice.payment_failed. - Who can cancel. The subscriber, the merchant, and the platform’s keeper. Subscribers sign a message and the platform submits it, so they never pay gas or hold the network’s token.
- Fee. A percentage of each settlement, taken inside
settle, goes to the platform treasury. The dashboard shows gross, fee and net on every Invoice.
contracts/src, with the Foundry test suite and invariants beside it.