Skip to content

Reference

getAmuletsForTransfer

Query unlocked Amulet contracts (and optionally reward coupons) for the acting sender from the ledger ACS, sorted largest-first for greedy spending.

getAmuletsForTransfer walks getActiveContracts results using the canonical JsActiveContract shape and filters to contracts owned by readAs[0] with positive balance. By default only Splice.Amulet:Amulet unlocked holdings are returned; enable includeAllTransferInputs to also surface AppRewardCoupon and ValidatorRewardCoupon inputs.

Use this before building AmuletRules_* exercises or wallet flows that must pick concrete contract IDs.

Setup

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

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

Minimal example

const inputs = await getAmuletsForTransfer({
  jsonApiClient: canton.ledger,
  readAs: ['SENDER_PARTY_ID'],
});

console.log(inputs.map((row) => row.contractId));

Parameters

GetAmuletsForTransferParams object:

  • jsonApiClient (required, LedgerJsonApiClient) — Ledger client used for getActiveContracts (typically canton.ledger).
  • readAs (optional, readonly string array) — Viewer scope; readAs[0] is treated as the sender party whose holdings are enumerated. If missing or empty, the helper returns [] without calling the ledger.
  • includeAllTransferInputs (optional, boolean) — When true, queries Amulet plus reward coupon templates; default false limits to unlocked Amulet contracts only.

Returns

Promise<AmuletForTransfer[]> — Sorted descending by effectiveAmount so greedy transfers consume large denominations first. Each row includes contractId, templateId, effectiveAmount, and owner.

Errors

Network and HTTP failures surface through the ledger client as usual. No bespoke ValidationError for empty readAs — you simply get an empty array.

Auth and party

Uses whatever identity / readAs scopes the ledger client allows. readAs[0] must be the party whose coins you intend to spend.

See also

Source

src/utils/amulet/get-amulets-for-transfer.ts