The minimum amount of tokens to select (in sats)
An async function that receives selected proofs and performs the operation. Should return any change proofs. All selected proofs are considered used.
Configuration options including mint filter, required couch, and optional custom token selection
// Use with NutzapProfile
await run(TokensOperation, 100, async ({ selectedProofs, mint, cashuWallet }) => {
const { keep, send } = await cashuWallet.ops.send(100, selectedProofs).asP2PK({ pubkey }).run();
await run(NutzapProfile, recipient, { mint, proofs: send, unit: "sat" });
return { change: keep };
}, { couch });
// Use with melt
await run(TokensOperation, meltAmount + feeReserve, async ({ selectedProofs, mint, cashuWallet }) => {
const meltQuote = await cashuWallet.createMeltQuoteBolt11(invoice);
const { keep, send } = await cashuWallet.send(meltAmount + meltQuote.fee_reserve, selectedProofs, { includeFees: true });
const meltResponse = await cashuWallet.meltProofs(meltQuote, send);
return { change: meltResponse.change };
}, { couch });
A generic action that safely selects tokens, performs an async operation, and handles change. This action requires a couch for safety - tokens are stored in the couch before the operation and can be recovered if something goes wrong.