Skip to content

Reference

PaymentStreams.paymentStreamFactory

Build the ExerciseCommand that creates a ProposedPaymentStream from a PaymentStreamFactory contract, including payer, recipient, per-day amounts, trial windows, and optional metadata.

The factory step instantiates a proposed payment stream: your actor (usually the payer) exercises PaymentStreamFactory_CreatePaymentStreamProposal with a structured proposal payload. Relative times are converted with relTimeToDAML internally; amounts map to DAML AmuletAmount / USDAmount tags.

Setup

import { OcpClient } from '@open-captable-protocol/canton';

const ocp = new OcpClient({ ledger: canton.ledger, validator: canton.validator });

Minimal example

const cmd = ocp.PaymentStreams.paymentStreamFactory.buildCreatePaymentStreamProposalCommand({
  factoryContractId: FACTORY_CONTRACT_ID,
  actor: PAYER_PARTY_ID,
  paymentStreamProposal: {
    payer: PAYER_PARTY_ID,
    recipient: RECIPIENT_PARTY_ID,
    provider: PROVIDER_PARTY_ID,
    recipientPaymentPerDay: { type: 'AMULET', amount: '1.0' },
    prepayWindow: '604800000000', // microseconds RelTime string before DAML conversion
    appRewardBeneficiaries: [],
    observers: [],
  },
});
await ocp.createBatch({ actAs: [PAYER_PARTY_ID] }).addBuiltCommand(cmd).submitAndWaitForTransactionTree();

Parameters — buildCreatePaymentStreamProposalCommand

  • factoryContractId (required) — On-chain id of the PaymentStreamFactory contract your network uses.
  • actor (required) — Party recorded in the choice argument (typically the payer).
  • paymentStreamProposal (required)PaymentStreamProposalInput:
    • payer, recipient, provider (required strings)
    • recipientPaymentPerDay (required){ type: 'AMULET' | 'USD', amount: string | number }
    • prepayWindow (required) — RelTime string in microseconds (e.g. '0' for none); converted for DAML.
    • appRewardBeneficiaries (optional) — default []
    • processorPaymentPerDay (optional) — same shape as recipient amount when set
    • freeTrialExpiration, paymentsEndAt (optional)PaymentStreamTimeInput: { type: 'PRECISE', value: Date } or { type: 'RELATIVE', value: string }
    • description, metadata, observers (optional)

Returns

CommandWithDisclosedContracts with disclosedContracts: [] from this builder. You may still need network-specific factory disclosure from utils when composing transactions with other cross-domain contracts.

Errors

This builder does not throw Ocp*. Invalid RelTime or type combinations are rejected by the participant at submit.

Auth and party

Submit with actAs authorized for the factory choice (payer / operator per deployment).

See also

Source