Skip to content

Reference

preApproveTransfers

Submit AmuletRules_CreateTransferPreapproval using disclosed mining-round context so receivers can accept prepaid transfers without per-leg negotiation.

preApproveTransfers stitches validatorClient reads (getAmuletRules, getDsoPartyId, getCurrentMiningRoundContext, lookupFeaturedAppRight) into submitAndWaitForTransactionTree exercised by readAs[0] (receiverPartyId). It pulls unlocked inputs via getAmuletsForTransfer for the receiver party and retries 409 LOCAL_VERDICT_LOCKED_CONTRACTS up to three times with exponential backoff.

Setup

import { preApproveTransfers } from '@fairmint/canton-node-sdk';

const canton = new Canton({
  network: 'NETWORK_NAME',
  partyId: 'PARTY_ID',
});

Minimal example

const result = await preApproveTransfers(canton.ledger, canton.validator, {
  receiverPartyId: 'RECEIVER_PARTY_ID',
});

console.log(result.contractId, result.domainId);

Parameters

PreApproveTransfersParams:

  • receiverPartyId (required, string) — Party receiving prepaid transfers — must match ledger actAs for submission.
  • providerPartyId (optional) — Defaults to receiverPartyId when omitted.
  • expiresAt (optional, Date) — Expiration timestamp for the preapproval record (defaults one year ahead).
  • contractDetails (optional) — Rare escape hatch if you already fetched blobs manually; normally omit so validators populate disclosures.

Ledger and validator clients are positional arguments (ledgerClient, validatorClient) ahead of params.

Returns

Promise<PreApproveTransfersResult> with contractId, domainId, amuletPaid (currently '0' placeholder in SDK).

Errors

  • OperationError with INSUFFICIENT_FUNDS when no unlocked Amulets exist for receiverPartyId.
  • OperationError TRANSACTION_FAILED when tree parsing cannot locate TransferPreapproval creation.
  • Propagates ApiError / ValidationError from nested helpers.

Auth and party

Submits as receiverPartyId (actAs). Receiver must already hold spendable Amulets because onboarding pays fees through AmuletRules_CreateTransferPreapproval.

See also

Source

src/utils/amulet/pre-approve-transfers.ts