createFactory deploys a new OCP Factory contract on the ledger. The factory is the root contract that lets you register issuer parties (via authorize) and create cap tables.
On mainnet and devnet the factory is already deployed — you don’t need to call this. Use it when setting up localnet, staging, or any custom Canton network.
Usage
import { Canton } from '@fairmint/canton-node-sdk';
import { createFactory, OcpClient } from '@open-captable-protocol/canton';
const canton = new Canton({ network: 'localnet' });
// Run once per Canton deployment
const factory = await createFactory(canton.ledger, {
systemOperator: 'YOUR_SYSTEM_OPERATOR_PARTY',
});
// Pass the result to OcpClient so authorize() finds your factory
const ocp = new OcpClient({
ledger: canton.ledger,
factory: {
contractId: factory.contractId,
templateId: factory.templateId,
},
});
Parameters
| Field | Required | Notes |
|---|---|---|
| client | ✓ | LedgerJsonApiClient from new Canton(...). |
| params.systemOperator | ✓ | Party ID of the system operator — becomes the factory’s sole signatory and admin. |
Returns
{
contractId: string; // the deployed OcpFactory contract ID
templateId: string; // the template ID to use in disclosures
updateId: string; // Canton transaction ID
}
Pass contractId and templateId as the factory option on new OcpClient(...).
Errors
| Scenario | Error |
|---|---|
| Created event not found in transaction tree | OcpContractError with RESULT_NOT_FOUND |