Everything flows through one object — OcpClient. Instantiate it once with your Canton clients, then call methods to read or write cap table data.
import { OcpClient } from '@open-captable-protocol/canton';
const ocp = new OcpClient({ ledger: canton.ledger });
Reads return ContractResult<T> — { data, contractId } where data is a typed OCF object.
Writes go through CapTableBatch — queue changes, execute atomically.
Setup & authorization
Before you can create a cap table, an issuer party must be registered with the OCP Factory.
| createFactory | Deploy an OCP Factory on a new Canton network. Not needed on mainnet or devnet. |
| authorize | Register an issuer party with the factory. Returns an IssuerAuthorization you pass to buildCreate. |
| withdraw | Revoke an issuer’s authorization. |
| issuer.buildCreate | Build the command to create an Issuer + CapTable in one transaction. |
Reading data
All getters take { contractId } and return ContractResult<T> — { data, contractId }.
Objects
| document.get | A document attached to the cap table. |
| issuer.get | The company — root of the cap table. |
| stakeholder.get | An individual or entity holding securities. |
| stockClass.get | A class of stock (common, preferred, etc.). |
| stockLegendTemplate.get | A stock legend template. |
| stockPlan.get | An equity incentive plan. |
| valuation.get | A company valuation record. |
| vestingTerms.get | Vesting schedule terms. |
Transactions — all follow the same get pattern.
Writing data
| Batch updates (CapTableBatch) | Queue creates / edits / deletes and submit atomically. Covers capTable.update, CapTableBatch, and buildUpdateCapTableCommand. |
Cap table lifecycle
| capTable.classify | Check if an issuer has an active cap table on the pinned package version. |
| capTable.getState | Snapshot of entity counts for a cap table. |
| capTable.archive | Archive the cap table and issuer (entity maps must be empty first). |
| archiveFullCapTable | Full teardown — sweeps all entities then archives. |
| getSystemOperatorPartyId | Resolve the system operator party for the current network. |
Errors & utils
| OcpError hierarchy | OcpValidationError, OcpContractError, OcpNetworkError, OcpParseError. |
| Types | ContractResult<T>, branded IDs, OCF output discriminants — usually inferred by TypeScript. |
| Validation | Entity validators, field guards, Zod schemas — use before submitting. |
| OCF data & conversions | Type guards, metadata, comparison, DAML↔OCF conversions. |
| Cap table state & sync | OCF manifest extraction, replication diffs, transaction helpers. |
Transport details (auth, HTTP, retries) are handled by @fairmint/canton-node-sdk — see the Canton Node SDK wiki.