Skip to content

Reference

Types — branded IDs

Nominal ContractId, PartyId, OcfId, SecurityId string brands with guards and validated conversions; unsafe casts for trusted strings.

Branded types prevent accidentally passing a contract id where a party id was expected at compile time. At runtime they remain plain strings; validation is non-empty for guards/converters unless you opt into unsafe*.

Core

  • ContractId, PartyId, OcfId, SecurityId
  • Guards: isContractId, isPartyId, isOcfId, isSecurityId
  • Validated:** toContractId, toPartyId, toOcfId, toSecurityId — throw Error if empty
  • Unsafe casts:** unsafeToContractId, unsafeToPartyId, unsafeToOcfId, unsafeToSecurityId

Example

import { toContractId, toPartyId } from '@open-captable-protocol/canton';

const cid = toContractId(RAW_CONTRACT_ID);
const issuer = toPartyId(RAW_PARTY_ID);

See also

  • common typesGetByContractIdParams uses raw string today; brands interoperate as strings.

Source