Canton Payroll Stream.
Canton Payroll Stream is an enterprise-grade continuous salary streaming application built on the Canton Network using Daml 3.5.1. It enables employers to fund an escrowed salary stream that accrues continuously to employees on a per-second basis, complete with native on-chain tax withholding. By utilizing Canton's synchronization domain privacy, salaries, participant identities, and payment histories remain strictly confidential between contracting parties while remaining verifiable.
- Role
- Distributed Systems & Daml Smart Contract Engineer
- Domain
- Enterprise privacy · Daml 3.5 · Canton Network · Continuous payroll · JSON Ledger API v2
System at a glance
What the system does
Canton sub-transaction ledger privacy
Lazy per-second salary accrual
Automated on-chain tax withholding
Reactive React UI with JSON Ledger API v2
Architecture flow
From intent to verified state.
- 01
An employer defines terms (rate/sec, tax rate, limit, escrow) and creates a PayrollStream contract on Canton.
- 02
The employee web UI calculates real-time earnings client-side using start timestamps without creating ledger transactions.
- 03
When the employee executes ClaimFunds, the Daml engine calculates elapsed time and deducts tax at ledger time.
- 04
The active contract is atomically archived and recreated with updated escrow and withdrawal counters.
- 05
Canton distributes sub-transaction trees strictly to signatory parties, keeping financial terms confidential.
01 / Smart contract domain
Single Daml template with lazy accrual mechanics
Modeling continuous payroll flows without spamming the distributed ledger.
Single-template contract model
Manages the entire stream lifecycle through PayrollStream, defining employer and employee signatories, balances, and choice permissions.
Lazy per-second accrual math
Eliminates the overhead of per-second ledger writes by calculating accrued amounts only when ClaimFunds is exercised against ledger time.
Integrated on-chain tax withholding
Automatically computes and deducts tax liabilities upon claim, recording net payout and withheld tax balances in the contract state.
02 / Confidential execution
Canton sub-transaction privacy guarantees
Partitioning transaction state so only contracting parties see financial terms.
Need-to-know transaction privacy
Canton encrypts and routes contract nodes strictly to the employer and employee, preventing competing participants on the network from viewing salaries.
Multi-party Daml contracts
The contract requires authorization from both employer and employee parties, ensuring neither party can unilaterally alter salary terms.
Participant-level audit overview
Provides a read-only overview mode using participant-wide filters to audit active streams and contract package schemas without leaking plaintext secrets.
03 / Ledger integration
Canton JSON Ledger API v2 and typed codegen
Direct browser integration with Canton nodes through type-safe generated bindings.
Custom JSON Ledger API v2 client
Hand-rolled TypeScript client for Canton's JSON Ledger API v2 with automatic command submission and error mapping.
Type-safe DAR codegen
Generates TypeScript interfaces directly from compiled Daml Archive (DAR) packages, guaranteeing payload encoding and choice argument correctness.
Package routing resolution
Implements dynamic normalization between package IDs and package name references (#canton-payroll-stream-main:Main:PayrollStream).
04 / Operational controls
Escrow management and stream state safety
Handling lifecycle edge cases, top-ups, and graceful termination.
State indicators and limits
The system transitions between Streaming, Ready to Claim, Low Escrow, and Limit Reached states based on elapsed time and balances.
Employer escrow top-ups
Allows employers to deposit additional funds into active streams without interrupting continuous employee accrual.
Controlled stream termination
Provides safe CloseStream choices enabling employers to settle remaining accrued wages and refund unvested escrow balances cleanly.