Payment Formula
Normal Sessions
For a standard work session, the verifier calculates:rate_per_ledger / LEDGERS_PER_UNIT × active_duration_seconds and compares it to the submitted amount. A mismatch causes the verify_work call to fail with a PaymentMismatch error.
Workers never enter their own payment amount. The verifier derives it from the tracked active seconds and the stream’s on-chain rate. The contract re-validates before any reservation is made.
Worked Example
0.20 XLM, the final reserved amount would be capped to 0.20 XLM instead.
Final Session Formula (--ended)
When a worker submits a final session with aven-stellar stop --ended, the remaining unreserved escrow is intended to cover the last payment in full. The server converts the remaining escrow into a contract-compatible duration argument:
active_duration_seconds argument to verify_work, ensuring the contract caps the verified amount to the exact remaining escrow — even if the worker’s real tracked active seconds were less.
The worker’s real npm-tracked active seconds are preserved separately in the report and displayed on the dashboard. The settlement seconds are recorded in the paymentRequest.settlementSeconds field for transparency.
Reservation vs Release
Payment flows through three distinct on-chain stages:
When the employer calls
approve_withdrawal, no tokens move yet — they remain in the contract. The tokens are transferred only when the worker subsequently calls withdraw_approved. This two-step design keeps the worker in control of when the transfer occurs.
A disputed session returns the reserved amount to the unreserved escrow pool. The worker and employer must resolve the dispute off-chain or through the dashboard before another session covering that work can be submitted.
Stellar Fixed-Point Amounts
All token amounts in Stellar are represented as 7-decimal fixed-point integers (stroops for XLM):rate_per_second, total_deposited, and payment amounts are all stored and calculated in this format on-chain. The Aven dashboard converts these values to human-readable decimals at the display boundary. When reading raw contract data or building integrations, always work in stroops and divide by 10,000,000 for display.