selectLockedAmuletForAmount filters LockedAmulet structs in memory:
effectiveAmount≥amountNeeded- Optional
requireExclusiveHolder(defaulttrue) rejects multi-holder locks. - Optional
rejectExpiredLocks(defaulttrue) rejects locks whoselockExpiresAtis in the past relative tonowMs.
Candidates sort ascending by effectiveAmount so the cheapest sufficient contract is chosen (avoids overspending).
Setup
import { selectLockedAmuletForAmount, getLockedAmuletsForParty } from '@fairmint/canton-node-sdk';
const canton = new Canton({
network: 'NETWORK_NAME',
partyId: 'PARTY_ID',
});
Minimal example
const locked = await getLockedAmuletsForParty(canton.validator, 'OWNER_PARTY_ID');
const choice = selectLockedAmuletForAmount(locked, 25.5, {
requireExclusiveHolder: true,
rejectExpiredLocks: true,
});
console.log(choice?.contractId ?? 'no match');
Parameters
amulets— Array ofLockedAmuletrows (for example fromgetLockedAmuletsForParty).amountNeeded— Positive finitenumberrepresenting the Amulet quantity to cover.options(optional) —LockedAmuletSelectionOptions:requireExclusiveHolder,rejectExpiredLocks,nowMs.
Returns
LockedAmulet | null — null when no contract satisfies constraints.
Errors
Throws ValidationError when amountNeeded is not finite or <= 0.
Auth and party
Pure function — no network. Apply only after fetching candidate rows with correct party scope.