What problem does it solve?
Helps developers implement the TypeScript half of Compact contracts by explaining compiler-generated types, the WitnessContext pattern, private state design, Compact-to-TypeScript type mappings, and how to bind witnesses to the Contract runtime so implementations type-check and interoperate with on-chain contracts.
Core Features & Use Cases
- Type mapping and runtime validation: clear mapping of Compact primitives and ADTs to TypeScript types and notes about runtime bounds and length checks.
- Witness implementation patterns: canonical WitnessContext usage, the [PrivateState, ReturnValue] tuple pattern, state-mutating and side-effect witnesses, ledger-reading witnesses, and contract-address keyed state scoping.
- Contract runtime & verification: guidance for using the generated Contract class, pureCircuits vs impureCircuits, ledger parsing, and mechanical verification to ensure witness implementations match compiled interfaces.
- Use Case: implement a local_secret_key witness that reads a 32-byte secret from private state, bind it to the compiled Contract, and run verification before deploying.
Quick Start
Implement a TypeScript witnesses file for mycontract that returns a 32-byte Uint8Array secret from private state, bind it to the generated Contract class, and verify the implementation against the compiled types.