Skip to main content
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)
tokenAmount
bigint
required
The amount of tokens to transfer
receiverSparkAddress
string
required
The recipient’s Spark Address
outputSelectionStrategy
string
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

txId
string
required
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);