Project case study Personal project

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

01

Canton sub-transaction ledger privacy

02

Lazy per-second salary accrual

03

Automated on-chain tax withholding

04

Reactive React UI with JSON Ledger API v2

Architecture flow

From intent to verified state.

  1. 01

    An employer defines terms (rate/sec, tax rate, limit, escrow) and creates a PayrollStream contract on Canton.

  2. 02

    The employee web UI calculates real-time earnings client-side using start timestamps without creating ledger transactions.

  3. 03

    When the employee executes ClaimFunds, the Daml engine calculates elapsed time and deducts tax at ledger time.

  4. 04

    The active contract is atomically archived and recreated with updated escrow and withdrawal counters.

  5. 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.

01.1

Single-template contract model

Manages the entire stream lifecycle through PayrollStream, defining employer and employee signatories, balances, and choice permissions.

01.2

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.

01.3

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.

02.1

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.

02.2

Multi-party Daml contracts

The contract requires authorization from both employer and employee parties, ensuring neither party can unilaterally alter salary terms.

02.3

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.

03.1

Custom JSON Ledger API v2 client

Hand-rolled TypeScript client for Canton's JSON Ledger API v2 with automatic command submission and error mapping.

03.2

Type-safe DAR codegen

Generates TypeScript interfaces directly from compiled Daml Archive (DAR) packages, guaranteeing payload encoding and choice argument correctness.

03.3

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.

04.1

State indicators and limits

The system transitions between Streaming, Ready to Claim, Low Escrow, and Limit Reached states based on elapsed time and balances.

04.2

Employer escrow top-ups

Allows employers to deposit additional funds into active streams without interrupting continuous employee accrual.

04.3

Controlled stream termination

Provides safe CloseStream choices enabling employers to settle remaining accrued wages and refund unvested escrow balances cleanly.

Continue exploring

More systems, protocols, and practical tools.