@fairmint/open-captable-protocol-daml-js

中文文档
0.5.1发布于 2026/11/06Apache-2.0TypeScriptCommonJS构建来源已验证近 30 天下载 1.8万

Open CapTable Protocol (OpenCapTable-v36, with OpenCapTableApi-v01) DAML contracts with generated JavaScript bindings. Other Fairmint DAML packages live in @fairmint/daml-js.

原始使用文档
文档目录5 节
  1. Packages
  2. Install and use the package
  3. Deployment
  4. Public documentation
  5. Build and validate

Open Cap Table Protocol DAML

This repository implements the Open Cap Format (OCF) as DAML contracts for Canton. It also publishes generated JavaScript bindings and the built DARs as @fairmint/open-captable-protocol-daml-js.

Packages

multi-package.yaml lists the DAML packages:

PackageWhat it holds
OpenCapTable-v36The register: OcpFactory, IssuerAuthorization, the CapTable anchor, one contract per OCF record, and the StockSecurity, StockClassEpoch and OcfIdShard states
OpenCapTableApi-v01The reader interfaces OcfObject and RegisterContract, whose views hold only builtin types (OCF object_type strings), since an interface package is never upgraded
TestDaml Script tests (not released)

OpenCapTable-v36 data-depends on OpenCapTableApi-v01, embeds it in its DAR and has no Splice dependency. The interfaces' comments name OpenCapTable-v35, the line they shipped with; the package never changes, so read them as the current register line (v36). Its design is ADR-040. v36 deploys to DevNet only; MainNet is out of scope. Older majors stay in dars/ and in git history.

Two more directories belong to v36:

  • ocf-extension/ holds the JSON schemas of the one Fairmint OCF extension, the hold pair TX_STOCK_HOLD / TX_STOCK_HOLD_CANCELLATION.
  • test-vectors/v35.json holds the derived-ID, claim-hash and floor-function vectors that the Daml tests, the SDK and apiv2 must all reproduce. v36 keeps the ID scheme v35 introduced, so the shared file keeps its name. npm run test:vectors recomputes them and checks the generated TestVectors.daml.

Install and use the package

npm install @fairmint/open-captable-protocol-daml-js

The browser-safe root entry point exports the generated Fairmint.OpenCapTable and Fairmint.OpenCapTableApi namespaces, the bundled DAML standard-library types, and the entry-point IDs:

import { Fairmint, OCP_INTERFACES, OCP_TEMPLATES } from '@fairmint/open-captable-protocol-daml-js';

OCP_TEMPLATES.capTable; // also ocpFactory, issuerAuthorization, stockSecurity, stockClassEpoch, ocfIdShard
OCP_INTERFACES.ocfObject; // and registerContract: what readers filter by

The package also exposes stable subpaths for deployment metadata and the DARs:

import factories from '@fairmint/open-captable-protocol-daml-js/ocp-factory-contract-id.json';
import {
  getOpenCapTableDarPaths,
  resolveOpenCapTableDarPath,
} from '@fairmint/open-captable-protocol-daml-js/openCapTableDarPath';

The v36 OcpFactory is consumed by each authorization, so ocp-factory-contract-id.json records each network's factory identity (templateId, system_operator, factory_id), not a contract ID. Find the live factory with an active-contracts query for that template, filtered on both fields. A network is absent until its factory is created.

The DARs are exported at ./opencaptable.dar (OpenCapTable-v36) and ./opencaptable-api.dar; getOpenCapTableDarPaths() lists both in upload order. Check package.json for the complete export map and scripts/test-imports.ts for the executable package-surface contract. resolveOpenCapTableDarPath checks OPEN_CAP_TABLE_DAR_PATH, then the packaged DAR, then optional local-checkout paths; see its source and options for exact resolution behavior.

Deployment

Every push to main publishes the npm package (publish.yml) and tags the commit v<npm version>. Publishing deploys nothing.

The ledger providers accept traffic only from allowlisted IPs, so the DARs are deployed by the Deploy OCP to ledger workflow of Fairmint/canton, from its allowlisted scripts box. Given an npm version, it:

  1. checks out this repository at that version's v<version> tag, or at the commit on main its ocp_daml_ref input names (for a version published without its tag), and runs the deployment preflight of npm run check:dar-version-policy for each DAR, dependency first;
  2. uploads and vets the published DARs on both DevNet participants and makes sure the OCP factory exists;
  3. records each deployment as the annotated tag dar-deploy/devnet/<package>/v<version> on that commit.

Those tags are the deployment evidence the DAR version policy reads. record_only records them for DARs that are already deployed. Record a factory identity the workflow reports in generated/ocp-factory-contract-id.json.

Public documentation

The public GitHub wiki is the canonical guide for contract architecture, OCF validation, development, testing, DAR backup, and release policy. Each package's daml.yaml, multi-package.yaml, package.json, and scripts/ remain the source of truth for current versions, dependencies, and automation.

Build and validate

Requires Node.js 22+ (see @fairmint/canton-dev-tools).

npm install
npx canton-dev-tools install-dpm-sdks
npm run build
npm test

npm run build generates OpenCapTable-v36/daml/Fairmint/OpenCapTable/OcfRecords.daml (the OCF record dispatch, from scripts/codegen/), runs prepare-build into generated/build/, then builds every package with dpm.

When generated bindings or the published npm surface are affected, also run:

npm run codegen
npm run verify-package

npm run check:schema-gaps compares the DAML types with the pinned OCF schemas (pass --ocf-schema-dir unless ../ocp-canton-sdk/libs/Open-Cap-Format-OCF is checked out) and with the extension in ocf-extension/.

The LocalNet OCF replay and cross-participant traffic scripts drove the ledger through ocp-canton-sdk, which does not support v36 yet. They were removed and return with SDK support; the last versions are in git history, the scripts before 0a15f5c and the replay-ocf-database workflow, with its sdk_ref input, at 7d693fa.

See Development and Testing for the generated-file boundary and specialized checks.

版本与发布记录

@fairmint/open-captable-protocol-daml-js 共发布 252 个版本,首次发布于 2025/08/07;过去 12 个月发布了 162 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.5.1latest2026/11/068 天前
0.5.02026/10/2916 天前
0.4.32026/10/2816 天前
0.4.22026/10/2817 天前
0.4.12026/10/2817 天前
0.4.02026/10/2222 天前

关于 @fairmint/open-captable-protocol-daml-js 的常见问题

@fairmint/open-captable-protocol-daml-js 是什么?

Open CapTable Protocol (OpenCapTable-v36, with OpenCapTableApi-v01) DAML contracts with generated JavaScript bindings. Other Fairmint DAML packages live in @fairmint/daml-js.

如何安装 @fairmint/open-captable-protocol-daml-js?

在项目目录运行 npm install @fairmint/open-captable-protocol-daml-js,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@daml/types(3.5.2)、@daml/ledger(2.10.4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fairmint/open-captable-protocol-daml-js 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fairmint/open-captable-protocol-daml-js 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fairmint/open-captable-protocol-daml-js 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fairmint/open-captable-protocol-daml-js 可以商用吗?

@fairmint/open-captable-protocol-daml-js 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@fairmint/open-captable-protocol-daml-js 的下载量有多少?

根据 npm 官方下载统计,@fairmint/open-captable-protocol-daml-js 在 2026/10/14 – 2026/11/12 这 30 天内被下载 17,715 次,日均约 591 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fairmint/open-captable-protocol-daml-js 还在维护吗?

最新版本 0.5.1 发布于 2026/11/06(8 天前);至今共发布 252 个版本,其中过去 12 个月发布了 162 个;首次发布于 2025/08/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。