Transfers tokens to another SparkWallet.
Method Signature
async transferTokens({
tokenIdentifier,
tokenAmount,
receiverSparkAddress,
outputSelectionStrategy,
selectedOutputs,
}: {
tokenIdentifier: Bech32mTokenIdentifier;
tokenAmount: bigint;
receiverSparkAddress: string;
outputSelectionStrategy?: "SMALL_FIRST" | "LARGE_FIRST";
selectedOutputs?: OutputWithPreviousTransactionData[];
}): Promise<string>
Parameters
tokenIdentifier
Bech32mTokenIdentifier
required
The Bech32m token identifier (format: btkn1... for mainnet, btknrt1... for regtest)
The amount of tokens to transfer
The recipient’s Spark Address
Strategy for selecting outputs: "SMALL_FIRST" or "LARGE_FIRST" (defaults to "SMALL_FIRST")
selectedOutputs
OutputWithPreviousTransactionData[]
Specific outputs to use for the transfer (overrides selection strategy)
Returns
The transaction ID of the token transfer
Example
const txId = await wallet.transferTokens({
tokenIdentifier: "btkn1...",
tokenAmount: 1000n,
receiverSparkAddress: "spark1..."
});
console.log("Token transfer completed:", txId);