Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.spark.money/llms.txt

Use this file to discover all available pages before exploring further.

Transfers tokens to another Spark Address via the IssuerSparkWallet.

Method Signature

async transferTokens({
  tokenIdentifier,
  tokenAmount,
  receiverSparkAddress,
  outputSelectionStrategy,
  selectedOutputs,
  executeBefore,
}: {
  tokenIdentifier: Bech32mTokenIdentifier;
  tokenAmount: bigint;
  receiverSparkAddress: string;
  outputSelectionStrategy?: "SMALL_FIRST" | "LARGE_FIRST";
  selectedOutputs?: OutputWithPreviousTransactionData[];
  executeBefore?: Date;
}): Promise<string>

Parameters

tokenIdentifier
Bech32mTokenIdentifier
required
Bech32m token identifier (eg: btkn1…) of the token to transfer
tokenAmount
bigint
required
Amount of tokens to transfer
receiverSparkAddress
string
required
Recipient’s Spark Address
outputSelectionStrategy
"SMALL_FIRST" | "LARGE_FIRST"
Strategy for selecting outputs: "SMALL_FIRST" or "LARGE_FIRST" (defaults to "SMALL_FIRST")
selectedOutputs
OutputWithPreviousTransactionData[]
Specific outputs to use for transfer (overrides selection strategy)
executeBefore
Date
Optional deadline for the transaction. If the transaction is not executed before this time, it will not be processed.

Returns

txId
string
required
Transaction ID

Example

const txId = await issuerWallet.transferTokens({
  tokenIdentifier: "btkn1...",
  tokenAmount: 1000n,
  receiverSparkAddress: "spark1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx"
});

console.log("Tokens transferred:", txId);